From 246990fd15c85c26d262ffe4587e739d21a36004 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Fri, 6 May 2022 10:21:32 -0500 Subject: Make modes in which to ignore open-paragraph a customization option --- lisp/acdw.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lisp/acdw.el') diff --git a/lisp/acdw.el b/lisp/acdw.el index a673e4a..10a51c1 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el @@ -139,6 +139,10 @@ active, or else the entire buffer." (= (line-beginning-position) (line-end-position))) (insert "\n"))))) +(defcustom +open-paragraph-ignore-modes '(special-mode lui-mode comint-mode) + "Modes in which `+open-paragraph' makes no sense." + :type '(repeat function)) + (defun +open-paragraph (&optional arg) "Open a paragraph after paragraph at point. A paragraph is defined as continguous non-empty lines of text @@ -149,7 +153,7 @@ Called with prefix ARG, open a paragraph before point." ;; TODO: Take an integer as ARG, allowing for skipping paragraphs up and down. (interactive "*P") ;; TODO: add `+open-paragraph-ignore-modes' - (unless (derived-mode-p 'special-mode 'lui-mode 'comint-mode) + (unless (apply #'derived-mode-p +open-paragraph-ignore-modes) ;; Go to next blank line. This /isn't/ `end-of-paragraph-text' because ;; that's weird with org, and I'm guessing other modes too. (unless (looking-at "^$") (forward-line (if arg -1 +1))) -- cgit 1.4.1-21-gabe81 From 1df15735b2fe65cf59ef9d3d84ad3175e35cb682 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Fri, 6 May 2022 10:21:51 -0500 Subject: Add +sort-lines --- lisp/acdw.el | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'lisp/acdw.el') diff --git a/lisp/acdw.el b/lisp/acdw.el index 10a51c1..171a109 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el @@ -431,5 +431,22 @@ This calls `indent-rigidly' and passes ARG to it." (goto-char (line-end-position))) (call-interactively #'indent-rigidly)) +(defun +sort-lines (reverse beg end) + "Sort lines in region, ignoring leading whitespace. +REVERSE non-nil means descending order; interactively, REVERSE is +the prefix argument, and BEG and END are the region. The +variable `sort-fold-case' determines whether case affects the +sort order." + (interactive "P\nr") + (save-excursion + (save-restriction + (narrow-to-region beg end) + (goto-char (point-min)) + (let ((inhibit-field-text-motion t)) + (sort-subr reverse + #'forward-line + #'end-of-line + #'beginning-of-line-text))))) + (provide 'acdw) ;;; acdw.el ends here -- cgit 1.4.1-21-gabe81