mirror of
https://github.com/jimeh/.emacs.d.git
synced 2026-02-19 13:46:41 +00:00
- Split large modules into smaller parts (e.g. siren-text-manipulation) - Organize modules into high level groups: - completion - core - editor - languages - linting - misc - navigation - projects - spelling - text-editing - version-control - windows - workspaces
25 lines
811 B
EmacsLisp
25 lines
811 B
EmacsLisp
;;; siren-randomize-region.el --- jimeh's Emacs Siren: randomize-region
|
|
|
|
;;; Commentary:
|
|
|
|
;; Helper command to randomize the order of lines in region. Shamelessly ripped
|
|
;; from: https://www.emacswiki.org/emacs/RandomizeBuffer
|
|
|
|
;;; Code:
|
|
|
|
(defun randomize-region (beg end)
|
|
"Randomize lines in region from BEG to END."
|
|
(interactive "*r")
|
|
(let ((lines (split-string
|
|
(delete-and-extract-region beg end) "\n")))
|
|
(when (string-equal "" (car (last lines 1)))
|
|
(setq lines (butlast lines 1)))
|
|
(apply 'insert
|
|
(mapcar 'cdr
|
|
(sort (mapcar
|
|
(lambda (x) (cons (random) (concat x "\n"))) lines)
|
|
(lambda (a b) (< (car a) (car b))))))))
|
|
|
|
(provide 'siren-randomize-region)
|
|
;;; siren-randomize-region.el ends here
|