diff options
author | Case Duckworth | 2022-05-06 10:21:51 -0500 |
---|---|---|
committer | Case Duckworth | 2022-05-06 10:21:51 -0500 |
commit | 1df15735b2fe65cf59ef9d3d84ad3175e35cb682 (patch) | |
tree | 5949267d6ecf1fe5e023fa44e20d112c99b8185a | |
parent | Make modes in which to ignore open-paragraph a customization option (diff) | |
download | emacs-1df15735b2fe65cf59ef9d3d84ad3175e35cb682.tar.gz emacs-1df15735b2fe65cf59ef9d3d84ad3175e35cb682.zip |
Add +sort-lines
-rw-r--r-- | lisp/acdw.el | 17 |
1 files changed, 17 insertions, 0 deletions
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." | |||
431 | (goto-char (line-end-position))) | 431 | (goto-char (line-end-position))) |
432 | (call-interactively #'indent-rigidly)) | 432 | (call-interactively #'indent-rigidly)) |
433 | 433 | ||
434 | (defun +sort-lines (reverse beg end) | ||
435 | "Sort lines in region, ignoring leading whitespace. | ||
436 | REVERSE non-nil means descending order; interactively, REVERSE is | ||
437 | the prefix argument, and BEG and END are the region. The | ||
438 | variable `sort-fold-case' determines whether case affects the | ||
439 | sort order." | ||
440 | (interactive "P\nr") | ||
441 | (save-excursion | ||
442 | (save-restriction | ||
443 | (narrow-to-region beg end) | ||
444 | (goto-char (point-min)) | ||
445 | (let ((inhibit-field-text-motion t)) | ||
446 | (sort-subr reverse | ||
447 | #'forward-line | ||
448 | #'end-of-line | ||
449 | #'beginning-of-line-text))))) | ||
450 | |||
434 | (provide 'acdw) | 451 | (provide 'acdw) |
435 | ;;; acdw.el ends here | 452 | ;;; acdw.el ends here |