mirror of
https://github.com/jimeh/.emacs.d.git
synced 2026-02-19 13:46:41 +00:00
I've set `lexical-binding` to `nil` in all Emacs Lisp files to suppress the warnings introduced in Emacs 31 requiring all elisp files to have a `lexical-binding` comment. This retains the default behavior of dynamic binding when no `lexical-binding` comment is present. With it set to `t` across the board, various things break, and fixing those is a task for another day.
25 lines
842 B
EmacsLisp
25 lines
842 B
EmacsLisp
;;; siren-randomize-region.el --- jimeh's Emacs Siren: randomize-region -*- lexical-binding: nil; -*-
|
|
|
|
;;; 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
|