diff options
-rw-r--r-- | init.el | 36 | ||||
-rw-r--r-- | lisp/acdw.el | 23 |
2 files changed, 11 insertions, 48 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 |
diff --git a/lisp/acdw.el b/lisp/acdw.el index 4043134..6e66838 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el | |||
@@ -330,26 +330,23 @@ In short, DO NOT USE THIS FUNCTION!!!" | |||
330 | (save-excursion | 330 | (save-excursion |
331 | (sort-sexps | 331 | (sort-sexps |
332 | (point-min) (point-max) | 332 | (point-min) (point-max) |
333 | (lambda (sexp) | 333 | ;; Key function |
334 | (format "%S" (cadr sexp))) | 334 | nil |
335 | ;; Sort function | ||
335 | (lambda (s1 s2) ; oh god, this is worse. | 336 | (lambda (s1 s2) ; oh god, this is worse. |
336 | (let* ((s1 (cdr s1)) (s2 (cdr s2)) ; for the strings themselves | 337 | (let* ((s1 (cdr s1)) (s2 (cdr s2)) ; for the strings themselves |
337 | (s1-require (string-match ":require" s1)) | 338 | (require-regexp (rx bos (* nonl) ":require")) |
338 | (s2-require (string-match ":require" s2)) | 339 | (straight-regexp (rx bos (* nonl) ":straight")) |
339 | (s1-straight (string-match ":straight" s1)) | 340 | (s1-require (string-match require-regexp s1)) |
340 | (s2-straight (string-match ":straight" s2)) | 341 | (s2-require (string-match require-regexp s2)) |
341 | (s1-bare (not (or s1-require s1-straight))) | 342 | (s1-straight (string-match straight-regexp s1)) |
342 | (s2-bare (not (or s2-require s2-straight)))) | 343 | (s2-straight (string-match straight-regexp s2))) |
343 | (cond | 344 | (cond |
344 | ;; if both are the same, sort regular style | 345 | ;; Straight forms require some weirdness |
345 | ((or (and s1-require s2-require) | ||
346 | (and s1-bare s2-bare)) | ||
347 | (string< s1 s2)) | ||
348 | ((and s1-straight s2-straight) | 346 | ((and s1-straight s2-straight) |
349 | (let* ((r (rx ":straight" (? "-if") (* space) (? "("))) | 347 | (let* ((r (rx ":straight" (? "-if") (* space) (? "("))) |
350 | (s1 (replace-regexp-in-string r "" s1)) | 348 | (s1 (replace-regexp-in-string r "" s1)) |
351 | (s2 (replace-regexp-in-string r "" s2))) | 349 | (s2 (replace-regexp-in-string r "" s2))) |
352 | (message "'%S' '%S'" s1 s2) | ||
353 | (string< s1 s2))) | 350 | (string< s1 s2))) |
354 | ;; requires should go first | 351 | ;; requires should go first |
355 | ((and s1-require (not s2-require)) t) | 352 | ((and s1-require (not s2-require)) t) |