about summary refs log tree commit diff stats
path: root/lisp/+setup.el
diff options
context:
space:
mode:
authorCase Duckworth2022-06-09 09:16:50 -0500
committerCase Duckworth2022-06-09 09:16:50 -0500
commit21b5d80814520540454c1167ca0495dd023c54dd (patch)
treeb50bd959b44f7dbb6986514f4f88540a848913c8 /lisp/+setup.el
parentblep (diff)
downloademacs-21b5d80814520540454c1167ca0495dd023c54dd.tar.gz
emacs-21b5d80814520540454c1167ca0495dd023c54dd.zip
Fix startup complaining
Diffstat (limited to 'lisp/+setup.el')
-rw-r--r--lisp/+setup.el58
1 files changed, 52 insertions, 6 deletions
diff --git a/lisp/+setup.el b/lisp/+setup.el index 1f110d6..a08526a 100644 --- a/lisp/+setup.el +++ b/lisp/+setup.el
@@ -43,6 +43,9 @@ it includes the NAME of the setup form in the warning output."
43 name) 43 name)
44 ,body))) 44 ,body)))
45 45
46
47;;; New forms
48
46(setup-define :quit 49(setup-define :quit
47 'setup-quit 50 'setup-quit
48 :documentation "Quit the current `setup' form. 51 :documentation "Quit the current `setup' form.
@@ -77,7 +80,16 @@ If PATH does not exist, abort the evaluation."
77 (file-name-nondirectory 80 (file-name-nondirectory
78 (directory-file-name (cadr args)))))) 81 (directory-file-name (cadr args))))))
79 82
83(setup-define :needs
84 (lambda (executable)
85 `(unless (executable-find ,executable)
86 ,(setup-quit)))
87 :documentation "If EXECUTABLE is not in the path, stop here."
88 :repeatable 1)
89
80 90
91;;; Package integrations
92
81;;; Straight.el 93;;; Straight.el
82 94
83(defun setup--straight-handle-arg (arg var) 95(defun setup--straight-handle-arg (arg var)
@@ -127,12 +139,46 @@ The following keyword arguments are also recognized:
127 (let ((recipe (cadr sexp))) 139 (let ((recipe (cadr sexp)))
128 (or (car-safe recipe) recipe))))) 140 (or (car-safe recipe) recipe)))))
129 141
130(setup-define :needs 142;;; Apheleia
131 (lambda (executable) 143
132 `(unless (executable-find ,executable) 144(setup-define :apheleia
133 ,(setup-quit))) 145 (lambda (name formatter &optional mode -pend)
134 :documentation "If EXECUTABLE is not in the path, stop here." 146 (let* ((mode (or mode (setup-get 'mode)))
135 :repeatable 1) 147 (current-formatters (and -pend
148 (alist-get mode apheleia-formatters))))
149 `(with-eval-after-load 'apheleia
150 (setf (alist-get ',name apheleia-formatters)
151 ,formatter)
152 (setf (alist-get ',mode apheleia-mode-alist)
153 ',(pcase -pend
154 (:append (append (ensure-list current-formatters)
155 (list name)))
156 (:prepend (cons name (ensure-list current-formatters)))
157 ('nil name)
158 (_ (error "Improper `:apheleia' -PEND argument")))))))
159 :documentation
160 "Register a formatter to `apheleia''s lists.
161NAME is the name given to the formatter in `apheleia-formatters'
162and `apheleia-mode-alist'. FORMATTER is the command paired with
163NAME in `apheleia-formatters'. MODE is the mode or modes to add
164NAME to in `apheleia-mode-alist'. If MODE is not given or nil,
165use the setup form's MODE. Optional argument -PEND can be one of
166`:append' or `:prepend', and if given will append or prepend the
167given NAME to the current formatters for the MODE in
168`apheleia-mode-alist', rather than replace them (the default).
169
170Example:
171(setup
172 (:apheleia isort (\"isort\" \"--stdout\" \"-\")
173 python-mode))
174; =>
175(progn
176 (setf (alist-get 'isort apheleia-formatters)
177 '(\"isort\" \"--stdout\" \"-\"))
178 (setf (alist-get 'python-mode apheleia-mode-alist)
179 'isort))
180
181This form cannot be repeated, and it cannot be used as HEAD.")
136 182
137 183
138;;; Redefines of `setup' forms 184;;; Redefines of `setup' forms