aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2018-12-02 10:32:25 -0800
committerGlenn Morris2018-12-02 10:32:25 -0800
commite5634aae531ce932ecb8d84243d690c7ca89bec3 (patch)
tree9b65030fca17dcb52be481ed229ad4b321cb866e
parent5f6d7a4f9d5970e6cb1dfc3bd8cdfa4651cf0678 (diff)
parent745c9c02582443680167501b218cc59f1a2d3fb6 (diff)
downloademacs-e5634aae531ce932ecb8d84243d690c7ca89bec3.tar.gz
emacs-e5634aae531ce932ecb8d84243d690c7ca89bec3.zip
Merge from origin/emacs-26
745c9c0 (origin/emacs-26) Revert "Revert "Fix infloop in GC mark_kboa... c418c85 Revert "Fix infloop in GC mark_kboards" 8fa0d96 * lisp/emacs-lisp/subr-x.el (if-let, when-let): Doc fix: acti...
-rw-r--r--lisp/emacs-lisp/subr-x.el29
1 files changed, 13 insertions, 16 deletions
diff --git a/lisp/emacs-lisp/subr-x.el b/lisp/emacs-lisp/subr-x.el
index 20eb0d5d05c..3d59af2505d 100644
--- a/lisp/emacs-lisp/subr-x.el
+++ b/lisp/emacs-lisp/subr-x.el
@@ -122,7 +122,7 @@ If ELT is of the form ((EXPR)), listify (EXPR) with a dummy symbol."
122 bindings))) 122 bindings)))
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 evaluate THEN or ELSE.
126This is like `if-let' but doesn't handle a VARLIST of the form 126This is like `if-let' but doesn't handle a VARLIST of the form
127\(SYMBOL SOMETHING) specially." 127\(SYMBOL SOMETHING) specially."
128 (declare (indent 2) 128 (declare (indent 2)
@@ -136,14 +136,14 @@ This is like `if-let' but doesn't handle a VARLIST of the form
136 `(let* () ,then))) 136 `(let* () ,then)))
137 137
138(defmacro when-let* (varlist &rest body) 138(defmacro when-let* (varlist &rest body)
139 "Bind variables according to VARLIST and conditionally eval BODY. 139 "Bind variables according to VARLIST and conditionally evaluate BODY.
140This is like `when-let' but doesn't handle a VARLIST of the form 140This is like `when-let' but doesn't handle a VARLIST of the form
141\(SYMBOL SOMETHING) specially." 141\(SYMBOL SOMETHING) specially."
142 (declare (indent 1) (debug if-let*)) 142 (declare (indent 1) (debug if-let*))
143 (list 'if-let* varlist (macroexp-progn body))) 143 (list 'if-let* varlist (macroexp-progn body)))
144 144
145(defmacro and-let* (varlist &rest body) 145(defmacro and-let* (varlist &rest body)
146 "Bind variables according to VARLIST and conditionally eval BODY. 146 "Bind variables according to VARLIST and conditionally evaluate BODY.
147Like `when-let*', except if BODY is empty and all the bindings 147Like `when-let*', except if BODY is empty and all the bindings
148are non-nil, then the result is non-nil." 148are non-nil, then the result is non-nil."
149 (declare (indent 1) 149 (declare (indent 1)
@@ -157,22 +157,20 @@ are non-nil, then the result is non-nil."
157 `(let* () ,@(or body '(t)))))) 157 `(let* () ,@(or body '(t))))))
158 158
159(defmacro if-let (spec then &rest else) 159(defmacro if-let (spec then &rest else)
160 "Bind variables according to SPEC and eval THEN or ELSE. 160 "Bind variables according to SPEC and evaluate THEN or ELSE.
161Each binding is evaluated in turn, and evaluation stops if a 161Evaluate each binding in turn, stopping if a binding value is nil.
162binding value is nil. If all are non-nil, the value of THEN is 162If all are non-nil return the value of THEN, otherwise the last form in ELSE.
163returned, or the last form in ELSE is returned.
164 163
165Each element of SPEC is a list (SYMBOL VALUEFORM) which binds 164Each element of SPEC is a list (SYMBOL VALUEFORM) that binds
166SYMBOL to the value of VALUEFORM. An element can additionally be 165SYMBOL to the value of VALUEFORM. An element can additionally be
167of the form (VALUEFORM), which is evaluated and checked for nil; 166of the form (VALUEFORM), which is evaluated and checked for nil;
168i.e. SYMBOL can be omitted if only the test result is of 167i.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 168interest. It can also be of the form SYMBOL, then the binding of
170SYMBOL is checked for nil. 169SYMBOL is checked for nil.
171 170
172As a special case, a SPEC of the form \(SYMBOL SOMETHING) is 171As a special case, interprets a SPEC of the form \(SYMBOL SOMETHING)
173interpreted like \((SYMBOL SOMETHING)). This exists for backward 172like \((SYMBOL SOMETHING)). This exists for backward compatibility
174compatibility with the old syntax that accepted only one 173with an old syntax that accepted only one binding."
175binding."
176 (declare (indent 2) 174 (declare (indent 2)
177 (debug ([&or (&rest [&or symbolp (symbolp form) (form)]) 175 (debug ([&or (&rest [&or symbolp (symbolp form) (form)])
178 (symbolp form)] 176 (symbolp form)]
@@ -184,10 +182,9 @@ binding."
184 (list 'if-let* spec then (macroexp-progn else))) 182 (list 'if-let* spec then (macroexp-progn else)))
185 183
186(defmacro when-let (spec &rest body) 184(defmacro when-let (spec &rest body)
187 "Bind variables according to SPEC and conditionally eval BODY. 185 "Bind variables according to SPEC and conditionally evaluate BODY.
188Each binding is evaluated in turn, and evaluation stops if a 186Evaluate each binding in turn, stopping if a binding value is nil.
189binding value is nil. If all are non-nil, the value of the last 187If all are non-nil, return the value of the last form in BODY.
190form in BODY is returned.
191 188
192The variable list SPEC is the same as in `if-let'." 189The variable list SPEC is the same as in `if-let'."
193 (declare (indent 1) (debug if-let)) 190 (declare (indent 1) (debug if-let))