Add sort-words function and sw alias to it

This commit is contained in:
2018-02-08 12:26:35 +00:00
parent 0942b0f30f
commit 93193c768e

View File

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