diff options
author | Case Duckworth | 2021-09-29 17:18:21 -0500 |
---|---|---|
committer | Case Duckworth | 2021-09-29 17:18:21 -0500 |
commit | 11f8a9e341be5779d568078813f3efa3ccb1e8e4 (patch) | |
tree | ecbc1724488583823e11ee5176d6a44308a078e0 /init.el | |
parent | Recipes (diff) | |
download | emacs-11f8a9e341be5779d568078813f3efa3ccb1e8e4.tar.gz emacs-11f8a9e341be5779d568078813f3efa3ccb1e8e4.zip |
Move sort-setups to acdw.el
Diffstat (limited to 'init.el')
-rw-r--r-- | init.el | 36 |
1 files changed, 1 insertions, 35 deletions
diff --git a/init.el b/init.el index a1d0f14..f1419c1 100644 --- a/init.el +++ b/init.el | |||
@@ -85,41 +85,7 @@ | |||
85 | 85 | ||
86 | (when-let ((default-directory | 86 | (when-let ((default-directory |
87 | (expand-file-name-exists-p "pkg/" user-emacs-directory))) | 87 | (expand-file-name-exists-p "pkg/" user-emacs-directory))) |
88 | (normal-top-level-add-subdirs-to-load-path)) | 88 | (normal-top-level-add-subdirs-to-load-path))) |
89 | |||
90 | (defun acdw/sort-setups () | ||
91 | "Sort `setup' forms in the current buffer. | ||
92 | Actually sorts all forms, but based on the logic of `setup'. | ||
93 | In short, DO NOT USE THIS FUNCTION!!!" | ||
94 | (save-excursion | ||
95 | (sort-sexps | ||
96 | (point-min) (point-max) | ||
97 | ;; Key function | ||
98 | nil | ||
99 | ;; Sort function | ||
100 | (lambda (s1 s2) ; oh god, this is worse. | ||
101 | (let* ((s1 (cdr s1)) (s2 (cdr s2)) ; for the strings themselves | ||
102 | (require-regexp (rx bos (* nonl) ":require")) | ||
103 | (straight-regexp (rx bos (* nonl) ":straight")) | ||
104 | (s1-require (string-match require-regexp s1)) | ||
105 | (s2-require (string-match require-regexp s2)) | ||
106 | (s1-straight (string-match straight-regexp s1)) | ||
107 | (s2-straight (string-match straight-regexp s2))) | ||
108 | (cond | ||
109 | ;; Straight forms require some weirdness | ||
110 | ((and s1-straight s2-straight) | ||
111 | (let* ((r (rx ":straight" (? "-if") (* space) (? "("))) | ||
112 | (s1 (replace-regexp-in-string r "" s1)) | ||
113 | (s2 (replace-regexp-in-string r "" s2))) | ||
114 | (string< s1 s2))) | ||
115 | ;; requires should go first | ||
116 | ((and s1-require (not s2-require)) t) | ||
117 | ((and (not s1-require) s2-require) nil) | ||
118 | ;; straights should go last | ||
119 | ((and s1-straight (not s2-straight)) nil) | ||
120 | ((and (not s1-straight) s2-straight) t) | ||
121 | ;; else, just sort em. | ||
122 | (t (string< s1 s2))))))))) | ||
123 | 89 | ||
124 | (setup autorevert | 90 | (setup autorevert |
125 | (:option global-auto-revert-non-file-buffers t | 91 | (:option global-auto-revert-non-file-buffers t |