Add +sort-lines

This commit is contained in:
Case Duckworth 2022-05-06 10:21:51 -05:00
parent 246990fd15
commit 1df15735b2
1 changed files with 17 additions and 0 deletions

View File

@ -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