From 93193c768e27ff38ecbaa0e37fae2ea75ac3bf36 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Thu, 8 Feb 2018 12:26:35 +0000 Subject: [PATCH] Add sort-words function and sw alias to it --- modules/siren-text-manipulation.el | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/modules/siren-text-manipulation.el b/modules/siren-text-manipulation.el index 527ec4e..ddc3af5 100644 --- a/modules/siren-text-manipulation.el +++ b/modules/siren-text-manipulation.el @@ -57,8 +57,22 @@ (lambda (x) (cons (random) (concat x "\n"))) lines) (lambda (a b) (< (car a) (car b)))))))) +;; from: https://www.emacswiki.org/emacs/SortWords +(defun sort-words (reverse beg end) + "Sort words in region alphabetically, in REVERSE if negative. +Prefixed with negative \\[universal-argument], sorts in reverse. + +The variable `sort-fold-case' determines whether alphabetic case +affects the sort order. + +See `sort-regexp-fields'." + (interactive "*P\nr") + (sort-regexp-fields reverse "\\w+" "\\&" beg end)) + (global-set-key (kbd "C-c /") 'comment-or-uncomment-region-or-line) (global-set-key (kbd "C-c C-/") 'comment-or-uncomment-region-or-line) +(defalias 'sw 'sort-words) + (provide 'siren-text-manipulation) ;;; siren-text-manipulation.el ends here