about summary refs log tree commit diff stats
path: root/lisp/+init.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/+init.el')
-rw-r--r--lisp/+init.el50
1 files changed, 26 insertions, 24 deletions
diff --git a/lisp/+init.el b/lisp/+init.el index 360a1b9..c1f3cb5 100644 --- a/lisp/+init.el +++ b/lisp/+init.el
@@ -37,41 +37,43 @@ are sorted lexigraphically."
37 nil 37 nil
38 ;; Sort function 38 ;; Sort function
39 (lambda (s1 s2) 39 (lambda (s1 s2)
40 (let ((s1 (cdr s1)) (s2 (cdr s2))) 40 (let ((s1 (cdr s1)) (s2 (cdr s2)))
41 (cond 41 (cond
42 ;; Sort everything /not/ `setup' /before/ `setup' 42 ;; Sort everything /not/ `setup' /before/ `setup'
43 ((and (+init--sexp-setup-p s1) 43 ((and (+init--sexp-setup-p s1)
44 (not (+init--sexp-setup-p s2))) 44 (not (+init--sexp-setup-p s2)))
45 nil) 45 nil)
46 ((and (+init--sexp-setup-p s2) 46 ((and (+init--sexp-setup-p s2)
47 (not (+init--sexp-setup-p s1))) 47 (not (+init--sexp-setup-p s1)))
48 t) 48 t)
49 ;; otherwise... 49 ;; otherwise...
50 (t (let ((s1-straight (+init--sexp-setup-p s1 :straight)) 50 (t (let ((s1-straight (+init--sexp-setup-p s1 :straight))
51 (s2-straight (+init--sexp-setup-p s2 :straight)) 51 (s2-straight (+init--sexp-setup-p s2 :straight))
52 (s1-require (+init--sexp-setup-p s1 :require)) 52 (s1-require (+init--sexp-setup-p s1 :require))
53 (s2-require (+init--sexp-setup-p s2 :require))) 53 (s2-require (+init--sexp-setup-p s2 :require)))
54 (cond 54 (cond
55 ;; `:straight' setups have extra processing 55 ;; `:straight' setups have extra processing
56 ((and s1-straight s2-straight) 56 ((and s1-straight s2-straight)
57 (let* ((r (rx (: ":straight" (? "-when") (* space) (? "(")))) 57 (let* ((r (rx (: ":straight" (? "-when") (* space) (? "("))))
58 (s1 (replace-regexp-in-string r "" s1)) 58 (s1 (replace-regexp-in-string r "" s1))
59 (s2 (replace-regexp-in-string r "" s2))) 59 (s2 (replace-regexp-in-string r "" s2)))
60 (string< s1 s2))) 60 (string< s1 s2)))
61 ;; `:require' setups go first 61 ;; `:require' setups go first
62 ((and s1-require (not s2-require)) t) 62 ((and s1-require (not s2-require)) t)
63 ((and s2-require (not s1-require)) nil) 63 ((and s2-require (not s1-require)) nil)
64 ;; `:straight' setups go last 64 ;; `:straight' setups go last
65 ((and s1-straight (not s2-straight)) nil) 65 ((and s1-straight (not s2-straight)) nil)
66 ((and s2-straight (not s1-straight)) t) 66 ((and s2-straight (not s1-straight)) t)
67 ;; otherwise, sort lexigraphically 67 ;; otherwise, sort lexigraphically
68 (t (string< s1 s2)))))))))))) 68 (t (string< s1 s2))))))))))))
69 69
70(defun +init-sort-then-save () 70(defun +init-sort-then-save ()
71 "Sort init.el, then save it." 71 "Sort init.el, then save it."
72 (interactive) 72 (interactive)
73 (+init-sort) 73 (+init-sort)
74 (save-buffer)) 74 (if (fboundp #'user-save-buffer)
75 (user-save-buffer)
76 (save-buffer)))
75 77
76;;; Add `setup' forms to `imenu-generic-expression' 78;;; Add `setup' forms to `imenu-generic-expression'
77 79
@@ -79,11 +81,11 @@ are sorted lexigraphically."
79 "Recognize `setup' forms in `imenu'." 81 "Recognize `setup' forms in `imenu'."
80 ;; `imenu-generic-expression' automatically becomes buffer-local when set 82 ;; `imenu-generic-expression' automatically becomes buffer-local when set
81 (setf (alist-get "Setup" imenu-generic-expression nil nil 'string-equal) 83 (setf (alist-get "Setup" imenu-generic-expression nil nil 'string-equal)
82 (list 84 (list
83 (rx (: bol (* space) 85 (rx (: bol (* space)
84 "(setup" (+ space) 86 "(setup" (+ space)
85 (group (? "(") (* nonl)))) 87 (group (? "(") (* nonl))))
86 1))) 88 1)))
87 89
88;;; Major mode 90;;; Major mode
89 91