aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/emacs-lisp/subr-x.el46
1 files changed, 26 insertions, 20 deletions
diff --git a/lisp/emacs-lisp/subr-x.el b/lisp/emacs-lisp/subr-x.el
index 21dba377bf1..7fab9083e85 100644
--- a/lisp/emacs-lisp/subr-x.el
+++ b/lisp/emacs-lisp/subr-x.el
@@ -123,15 +123,8 @@ If ELT is of the form ((EXPR)), listify (EXPR) with a dummy symbol."
123 123
124(defmacro if-let* (varlist then &rest else) 124(defmacro if-let* (varlist then &rest else)
125 "Bind variables according to VARLIST and eval THEN or ELSE. 125 "Bind variables according to VARLIST and eval THEN or ELSE.
126Each binding is evaluated in turn, and evaluation stops if a 126This is like `if-let' but doesn't handle a VARLIST of the form
127binding value is nil. If all are non-nil, the value of THEN is 127\(SYMBOL SOMETHING) specially."
128returned, or the last form in ELSE is returned.
129
130Each element of VARLIST is a list (SYMBOL VALUEFORM) which binds
131SYMBOL to the value of VALUEFORM. An element can additionally
132be of the form (VALUEFORM), which is evaluated and checked for
133nil; i.e. SYMBOL can be omitted if only the test result is of
134interest."
135 (declare (indent 2) 128 (declare (indent 2)
136 (debug ((&rest [&or symbolp (symbolp form) (form)]) 129 (debug ((&rest [&or symbolp (symbolp form) (form)])
137 form body))) 130 form body)))
@@ -144,11 +137,8 @@ interest."
144 137
145(defmacro when-let* (varlist &rest body) 138(defmacro when-let* (varlist &rest body)
146 "Bind variables according to VARLIST and conditionally eval BODY. 139 "Bind variables according to VARLIST and conditionally eval BODY.
147Each binding is evaluated in turn, and evaluation stops if a 140This is like `when-let' but doesn't handle a VARLIST of the form
148binding value is nil. If all are non-nil, the value of the last 141\(SYMBOL SOMETHING) specially."
149form in BODY is returned.
150
151VARLIST is the same as in `if-let*'."
152 (declare (indent 1) (debug if-let*)) 142 (declare (indent 1) (debug if-let*))
153 (list 'if-let* varlist (macroexp-progn body))) 143 (list 'if-let* varlist (macroexp-progn body)))
154 144
@@ -168,12 +158,25 @@ are non-nil, then the result is non-nil."
168 158
169(defmacro if-let (spec then &rest else) 159(defmacro if-let (spec then &rest else)
170 "Bind variables according to SPEC and eval THEN or ELSE. 160 "Bind variables according to SPEC and eval THEN or ELSE.
171Like `if-let*' except SPEC can have the form (SYMBOL VALUEFORM)." 161Each binding is evaluated in turn, and evaluation stops if a
162binding value is nil. If all are non-nil, the value of THEN is
163returned, or the last form in ELSE is returned.
164
165Each element of SPEC is a list (SYMBOL VALUEFORM) which binds
166SYMBOL to the value of VALUEFORM. An element can additionally be
167of the form (VALUEFORM), which is evaluated and checked for nil;
168i.e. SYMBOL can be omitted if only the test result is of
169interest. It can also be of the form SYMBOL, then the binding of
170SYMBOL is checked for nil.
171
172As a special case, a SPEC of the form \(SYMBOL SOMETHING) is
173interpreted like \((SYMBOL SOMETHING)). This exists for backward
174compatibility with the old syntax that accepted only one
175binding."
172 (declare (indent 2) 176 (declare (indent 2)
173 (debug ([&or (&rest [&or symbolp (symbolp form) (form)]) 177 (debug ([&or (&rest [&or symbolp (symbolp form) (form)])
174 (symbolp form)] 178 (symbolp form)]
175 form body)) 179 form body)))
176 (obsolete "use `if-let*' instead." "26.1"))
177 (when (and (<= (length spec) 2) 180 (when (and (<= (length spec) 2)
178 (not (listp (car spec)))) 181 (not (listp (car spec))))
179 ;; Adjust the single binding case 182 ;; Adjust the single binding case
@@ -182,9 +185,12 @@ Like `if-let*' except SPEC can have the form (SYMBOL VALUEFORM)."
182 185
183(defmacro when-let (spec &rest body) 186(defmacro when-let (spec &rest body)
184 "Bind variables according to SPEC and conditionally eval BODY. 187 "Bind variables according to SPEC and conditionally eval BODY.
185Like `when-let*' except SPEC can have the form (SYMBOL VALUEFORM)." 188Each binding is evaluated in turn, and evaluation stops if a
186 (declare (indent 1) (debug if-let) 189binding value is nil. If all are non-nil, the value of the last
187 (obsolete "use `when-let*' instead." "26.1")) 190form in BODY is returned.
191
192The variable list SPEC is the same as in `if-let'."
193 (declare (indent 1) (debug if-let))
188 (list 'if-let spec (macroexp-progn body))) 194 (list 'if-let spec (macroexp-progn body)))
189 195
190(defsubst hash-table-empty-p (hash-table) 196(defsubst hash-table-empty-p (hash-table)