From 11f8a9e341be5779d568078813f3efa3ccb1e8e4 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 29 Sep 2021 17:18:21 -0500 Subject: Move sort-setups to acdw.el --- lisp/acdw.el | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'lisp/acdw.el') 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!!!" (save-excursion (sort-sexps (point-min) (point-max) - (lambda (sexp) - (format "%S" (cadr sexp))) + ;; Key function + nil + ;; Sort function (lambda (s1 s2) ; oh god, this is worse. (let* ((s1 (cdr s1)) (s2 (cdr s2)) ; for the strings themselves - (s1-require (string-match ":require" s1)) - (s2-require (string-match ":require" s2)) - (s1-straight (string-match ":straight" s1)) - (s2-straight (string-match ":straight" s2)) - (s1-bare (not (or s1-require s1-straight))) - (s2-bare (not (or s2-require s2-straight)))) + (require-regexp (rx bos (* nonl) ":require")) + (straight-regexp (rx bos (* nonl) ":straight")) + (s1-require (string-match require-regexp s1)) + (s2-require (string-match require-regexp s2)) + (s1-straight (string-match straight-regexp s1)) + (s2-straight (string-match straight-regexp s2))) (cond - ;; if both are the same, sort regular style - ((or (and s1-require s2-require) - (and s1-bare s2-bare)) - (string< s1 s2)) + ;; Straight forms require some weirdness ((and s1-straight s2-straight) (let* ((r (rx ":straight" (? "-if") (* space) (? "("))) (s1 (replace-regexp-in-string r "" s1)) (s2 (replace-regexp-in-string r "" s2))) - (message "'%S' '%S'" s1 s2) (string< s1 s2))) ;; requires should go first ((and s1-require (not s2-require)) t) -- cgit 1.4.1-21-gabe81