Re-sort init.el

This commit is contained in:
Case Duckworth 2021-09-15 23:32:16 -05:00
parent f3c9b7c3d9
commit 5380cfb762
2 changed files with 915 additions and 888 deletions

1782
init.el

File diff suppressed because it is too large Load Diff

View File

@ -265,10 +265,16 @@ With a prefix argument N, (un)comment that many sexps."
;; from https://github.com/alphapapa/unpackaged.el#sort-sexps ;; from https://github.com/alphapapa/unpackaged.el#sort-sexps
;; and https://github.com/alphapapa/unpackaged.el/issues/20 ;; and https://github.com/alphapapa/unpackaged.el/issues/20
(defun sort-sexps (beg end &optional key) (defun sort-sexps (beg end &optional key-fn sort-fn)
"Sort sexps between BEG and END. "Sort sexps between BEG and END.
Comments stay with the code below. KEY is a function to sort by, Comments stay with the code below.
e.g. (lambda (sexp) (symbol-name (car sexp)))"
Optional argument KEY-FN will determine where in each sexp to
start sorting. e.g. (lambda (sexp) (symbol-name (car sexp)))
Optional argument SORT-FN will determine how to sort two sexps'
strings. It's passed to `sort'. By default, it sorts the sexps
with `string<' starting with the key determined by KEY-FN."
(interactive "r") (interactive "r")
(cl-flet ((skip-whitespace () (while (looking-at (rx (1+ (or space "\n")))) (cl-flet ((skip-whitespace () (while (looking-at (rx (1+ (or space "\n"))))
(goto-char (match-end 0)))) (goto-char (match-end 0))))
@ -298,8 +304,8 @@ e.g. (lambda (sexp) (symbol-name (car sexp)))"
(save-excursion (save-excursion
(goto-char (marker-position start)) (goto-char (marker-position start))
(skip-both) (skip-both)
(if key (if key-fn
(funcall key sexp) (funcall key-fn sexp)
(buffer-substring (buffer-substring
(point) (point)
(marker-position end))))) (marker-position end)))))
@ -307,8 +313,9 @@ e.g. (lambda (sexp) (symbol-name (car sexp)))"
collect (cons start end) collect (cons start end)
into markers into markers
finally return (list sexps markers)) finally return (list sexps markers))
(setq sexps (sort sexps (lambda (a b) (setq sexps (sort sexps (if sort-fn sort-fn
(string< (cdr a) (cdr b))))) (lambda (a b)
(string< (cdr a) (cdr b))))))
(cl-loop for (real . sort) in sexps (cl-loop for (real . sort) in sexps
for (start . end) in markers for (start . end) in markers
do (progn do (progn