diff options
Diffstat (limited to 'lisp/+apheleia.el')
-rw-r--r-- | lisp/+apheleia.el | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/lisp/+apheleia.el b/lisp/+apheleia.el index df651b8..9ed731c 100644 --- a/lisp/+apheleia.el +++ b/lisp/+apheleia.el | |||
@@ -2,7 +2,6 @@ | |||
2 | 2 | ||
3 | ;;; Code: | 3 | ;;; Code: |
4 | 4 | ||
5 | (require 'apheleia) | ||
6 | (require 'cl-lib) | 5 | (require 'cl-lib) |
7 | 6 | ||
8 | ;; https://github.com/raxod502/apheleia/pull/63#issue-1077529623 | 7 | ;; https://github.com/raxod502/apheleia/pull/63#issue-1077529623 |
@@ -14,49 +13,5 @@ | |||
14 | (point-max)) | 13 | (point-max)) |
15 | (funcall callback))) | 14 | (funcall callback))) |
16 | 15 | ||
17 | |||
18 | ;;; `setup' integration | ||
19 | |||
20 | (require 'setup) | ||
21 | |||
22 | (setup-define :apheleia | ||
23 | (lambda (name formatter &optional mode -pend) | ||
24 | (let* ((mode (or mode (setup-get 'mode))) | ||
25 | (current-formatters (and -pend | ||
26 | (alist-get mode apheleia-formatters)))) | ||
27 | `(progn | ||
28 | (setf (alist-get ',name apheleia-formatters) | ||
29 | ,formatter) | ||
30 | (setf (alist-get ',mode apheleia-mode-alist) | ||
31 | ',(pcase -pend | ||
32 | (:append (append (ensure-list current-formatters) | ||
33 | (list name))) | ||
34 | (:prepend (cons name (ensure-list current-formatters))) | ||
35 | ('nil name) | ||
36 | (_ (error "Improper `:apheleia' -PEND argument"))))))) | ||
37 | :documentation | ||
38 | "Register a formatter to `apheleia''s lists. | ||
39 | NAME is the name given to the formatter in `apheleia-formatters' | ||
40 | and `apheleia-mode-alist'. FORMATTER is the command paired with | ||
41 | NAME in `apheleia-formatters'. MODE is the mode or modes to add | ||
42 | NAME to in `apheleia-mode-alist'. If MODE is not given or nil, | ||
43 | use the setup form's MODE. Optional argument -PEND can be one of | ||
44 | `:append' or `:prepend', and if given will append or prepend the | ||
45 | given NAME to the current formatters for the MODE in | ||
46 | `apheleia-mode-alist', rather than replace them (the default). | ||
47 | |||
48 | Example: | ||
49 | (setup | ||
50 | (:apheleia isort (\"isort\" \"--stdout\" \"-\") | ||
51 | python-mode)) | ||
52 | ; => | ||
53 | (progn | ||
54 | (setf (alist-get 'isort apheleia-formatters) | ||
55 | '(\"isort\" \"--stdout\" \"-\")) | ||
56 | (setf (alist-get 'python-mode apheleia-mode-alist) | ||
57 | 'isort)) | ||
58 | |||
59 | This form cannot be repeated, and it cannot be used as HEAD.") | ||
60 | |||
61 | (provide '+apheleia) | 16 | (provide '+apheleia) |
62 | ;;; +apheleia.el ends here | 17 | ;;; +apheleia.el ends here |