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') 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