about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2022-02-07 13:16:04 -0600
committerCase Duckworth2022-02-07 13:16:04 -0600
commit50d7ff8077f61bf1d91be9927dbd9117337a1b85 (patch)
tree951d87758e286308457c6637ce79c9d2a22838da
parentAdd bongo (diff)
downloademacs-50d7ff8077f61bf1d91be9927dbd9117337a1b85.tar.gz
emacs-50d7ff8077f61bf1d91be9927dbd9117337a1b85.zip
Add :load-from
-rw-r--r--lisp/+setup.el93
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.
52This macro can be used as NAME, and it will replace itself with
53the nondirectory part of PATH.
54If 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'.
64This macro can be used as HEAD, and will replace itself with the 83This macro can be used as HEAD, and will replace itself with the
65first RECIPE's package." 84first 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.
76This macro can be used as HEAD, and will replace itself with the 95This macro can be used as HEAD, and will replace itself with the
77first RECIPE's package." 96first 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.
90If CONDITION is false, or if `straight-use-package' fails, stop 109If CONDITION is false, or if `straight-use-package' fails, stop
91evaluating the body. This macro can be used as HEAD, and will 110evaluating the body. This macro can be used as HEAD, and will
92replace itself with the RECIPE's package." 111replace 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