branch: externals/setup
commit 2f4a33b7a941684fefffd90391b76fbafa0ed212
Author: Philip Kaludercic <phil...@posteo.net>
Commit: Philip Kaludercic <phil...@posteo.net>

    Add :and macro
---
 setup.el | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/setup.el b/setup.el
index 52434f2dd3..f3560e3f29 100644
--- a/setup.el
+++ b/setup.el
@@ -642,6 +642,22 @@ yourself."
   :after-loaded t
   :indent 0)
 
+(setup-define :and
+  (lambda (&rest conds)
+    `(if (and ,@(butlast conds))
+         ,@(last conds)
+       ,(setup-quit)))
+  :documentation "Abort evaluation of CONDS are not all true.
+The expression of the last condition is used to deduce the
+feature context."
+  :shorthand
+  (lambda (head)
+    (unless (cdr head)
+      (error ":and requires at least one condition"))
+    (let ((shorthand (get (caar (last head)) 'setup-shorthand)))
+      (and shorthand (funcall shorthand (car (last head))))))
+  :debug '(setup))
+
 
 ;;; Obsoleted code
 

Reply via email to