branch: externals/setup commit 0bf5c62ac3bf3f37dd200c4e2b783266725d9422 Author: Philip K <phil...@posteo.net> Commit: Philip K <phil...@posteo.net>
Add :with-feature macro --- setup.el | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/setup.el b/setup.el index 8a65486..8370fc2 100644 --- a/setup.el +++ b/setup.el @@ -102,14 +102,10 @@ The following local macros are defined in a `setup' body:\n\n" (when shorthand (push name body) (setq name (funcall shorthand name))))) - (let ((mode (if (string-match-p "-mode\\'" (symbol-name name)) - name - (intern (format "%s-mode" name))))) - `(let ((setup-name ',name)) - (ignore setup-name) - (cl-macrolet ,setup-macros - (catch 'setup-exit - (:with-mode ,mode ,@body)))))) + `(cl-macrolet ,setup-macros + (catch 'setup-exit + (:with-feature ,name ,@body) + t))) ;;;###autoload (put 'setup 'function-documentation '(setup-make-docstring)) @@ -170,6 +166,18 @@ A documentation string." ;;; definitions of `setup' keywords +(setup-define :with-feature + (lambda (name &rest body) + `(let ((setup-name ',name)) + (ignore setup-name) + (:with-mode ,(if (string-match-p "-mode\\'" (symbol-name name)) + name + (intern (format "%s-mode" name))) + ,@body))) + :signature '(SYSTEM &body BODY) + :documentation "Change the SYSTEM that BODY is configuring." + :indent 1) + (setup-define :with-mode (lambda (mode &rest body) `(let ((setup-mode ',mode)