diff options
Diffstat (limited to 'lisp/+setup.el')
-rw-r--r-- | lisp/+setup.el | 93 |
1 files changed, 56 insertions, 37 deletions
diff --git a/lisp/+setup.el b/lisp/+setup.el index d8e9bb8..c77cb36 100644 --- a/lisp/+setup.el +++ b/lisp/+setup.el | |||
@@ -42,57 +42,76 @@ | |||
42 | body)) | 42 | body)) |
43 | :documentation "Load the current feature after FEATURES.") | 43 | :documentation "Load the current feature after FEATURES.") |
44 | 44 | ||
45 | (setup-define :also-straight | 45 | (setup-define :load-from |
46 | (lambda (path) | ||
47 | `(let ((path* (expand-file-name ,path))) | ||
48 | (if (file-exists-p path*) | ||
49 | (add-to-list 'load-path path*) | ||
50 | ,(setup-quit)))) | ||
51 | :documentation "Add PATH to load path. | ||
52 | This macro can be used as NAME, and it will replace itself with | ||
53 | the nondirectory part of PATH. | ||
54 | If PATH does not exist, abort the evaluation." | ||
55 | :shorthand (lambda (args) | ||
56 | (intern | ||
57 | (file-name-nondirectory | ||
58 | (directory-file-name (cadr args)))))) | ||
59 | |||
60 | |||
61 | ;;; Straight.el | ||
62 | |||
63 | (with-eval-after-load 'straight | ||
64 | (setup-define :also-straight | ||
46 | (lambda (recipe) `(setup (:straight ,recipe))) | 65 | (lambda (recipe) `(setup (:straight ,recipe))) |
47 | :documentation | 66 | :documentation |
48 | "Install RECIPE with `straight-use-package', after loading FEATURE." | 67 | "Install RECIPE with `straight-use-package', after loading FEATURE." |
49 | :repeatable t | 68 | :repeatable t |
50 | :after-loaded t) | 69 | :after-loaded t) |
51 | 70 | ||
52 | (defun +setup-straight-shorthand (sexp) | 71 | (defun +setup-straight-shorthand (sexp) |
53 | "Shorthand for `:straight' and other local macros." | 72 | "Shorthand for `:straight' and other local macros." |
54 | (let ((recipe (cadr sexp))) | 73 | (let ((recipe (cadr sexp))) |
55 | (or (car-safe recipe) recipe))) | 74 | (or (car-safe recipe) recipe))) |
56 | 75 | ||
57 | (setup-define :straight | 76 | (setup-define :straight |
58 | (lambda (recipe) | 77 | (lambda (recipe) |
59 | `(unless (ignore-errors (straight-use-package ',recipe) t) | 78 | `(unless (ignore-errors (straight-use-package ',recipe) t) |
60 | (+setup-warn ":straight error: %S" ',recipe) | 79 | (+setup-warn ":straight error: %S" ',recipe) |
61 | ,(setup-quit))) | 80 | ,(setup-quit))) |
62 | :documentation | 81 | :documentation |
63 | "Install RECIPE with `straight-use-package'. | 82 | "Install RECIPE with `straight-use-package'. |
64 | This macro can be used as HEAD, and will replace itself with the | 83 | This macro can be used as HEAD, and will replace itself with the |
65 | first RECIPE's package." | 84 | first RECIPE's package." |
66 | :repeatable t | 85 | :repeatable t |
67 | :shorthand #'+setup-straight-shorthand) | 86 | :shorthand #'+setup-straight-shorthand) |
68 | 87 | ||
69 | (setup-define :straight-after | 88 | (setup-define :straight-after |
70 | (lambda (recipe feature) | 89 | (lambda (recipe feature) |
71 | `(with-eval-after-load ,feature | 90 | `(with-eval-after-load ,feature |
72 | (setup (:straight ,recipe)))) | 91 | (setup (:straight ,recipe)))) |
73 | :indent 1 | 92 | :indent 1 |
74 | :documentation | 93 | :documentation |
75 | "Install RECIPE with `straight-use-package', after FEATURE. | 94 | "Install RECIPE with `straight-use-package', after FEATURE. |
76 | This macro can be used as HEAD, and will replace itself with the | 95 | This macro can be used as HEAD, and will replace itself with the |
77 | first RECIPE's package." | 96 | first RECIPE's package." |
78 | :shorthand #'+setup-straight-shorthand) | 97 | :shorthand #'+setup-straight-shorthand) |
79 | 98 | ||
80 | (setup-define :straight-when | 99 | (setup-define :straight-when |
81 | (lambda (recipe condition) | 100 | (lambda (recipe condition) |
82 | `(if ,condition | 101 | `(if ,condition |
83 | (unless (ignore-errors (straight-use-package ',recipe) t) | 102 | (unless (ignore-errors (straight-use-package ',recipe) t) |
84 | (+setup-warn ":straight error: %S" ',recipe) | 103 | (+setup-warn ":straight error: %S" ',recipe) |
85 | ,(setup-quit)) | 104 | ,(setup-quit)) |
86 | (message "Setup: :straight-when returned nil %S" ',recipe) | 105 | (message "Setup: :straight-when returned nil %S" ',recipe) |
87 | ,(setup-quit))) | 106 | ,(setup-quit))) |
88 | :documentation | 107 | :documentation |
89 | "Install RECIPE with `straight-use-package' when CONDITION is met. | 108 | "Install RECIPE with `straight-use-package' when CONDITION is met. |
90 | If CONDITION is false, or if `straight-use-package' fails, stop | 109 | If CONDITION is false, or if `straight-use-package' fails, stop |
91 | evaluating the body. This macro can be used as HEAD, and will | 110 | evaluating the body. This macro can be used as HEAD, and will |
92 | replace itself with the RECIPE's package." | 111 | replace itself with the RECIPE's package." |
93 | :repeatable 2 | 112 | :repeatable 2 |
94 | :indent 1 | 113 | :indent 1 |
95 | :shorthand #'+setup-straight-shorthand) | 114 | :shorthand #'+setup-straight-shorthand)) |
96 | 115 | ||
97 | 116 | ||
98 | ;;; Redefines of `setup' forms | 117 | ;;; Redefines of `setup' forms |