* lisp/emacs-lisp/subr-x.el (if-let, when-let): Doc fix: active voice.

This commit is contained in:
Glenn Morris 2018-12-01 17:21:29 -08:00
parent af914fc26d
commit 8fa0d9679d

View file

@ -122,7 +122,7 @@ If ELT is of the form ((EXPR)), listify (EXPR) with a dummy symbol."
bindings))) bindings)))
(defmacro if-let* (varlist then &rest else) (defmacro if-let* (varlist then &rest else)
"Bind variables according to VARLIST and eval THEN or ELSE. "Bind variables according to VARLIST and evaluate THEN or ELSE.
This is like `if-let' but doesn't handle a VARLIST of the form This is like `if-let' but doesn't handle a VARLIST of the form
\(SYMBOL SOMETHING) specially." \(SYMBOL SOMETHING) specially."
(declare (indent 2) (declare (indent 2)
@ -136,14 +136,14 @@ This is like `if-let' but doesn't handle a VARLIST of the form
`(let* () ,then))) `(let* () ,then)))
(defmacro when-let* (varlist &rest body) (defmacro when-let* (varlist &rest body)
"Bind variables according to VARLIST and conditionally eval BODY. "Bind variables according to VARLIST and conditionally evaluate BODY.
This is like `when-let' but doesn't handle a VARLIST of the form This is like `when-let' but doesn't handle a VARLIST of the form
\(SYMBOL SOMETHING) specially." \(SYMBOL SOMETHING) specially."
(declare (indent 1) (debug if-let*)) (declare (indent 1) (debug if-let*))
(list 'if-let* varlist (macroexp-progn body))) (list 'if-let* varlist (macroexp-progn body)))
(defmacro and-let* (varlist &rest body) (defmacro and-let* (varlist &rest body)
"Bind variables according to VARLIST and conditionally eval BODY. "Bind variables according to VARLIST and conditionally evaluate BODY.
Like `when-let*', except if BODY is empty and all the bindings Like `when-let*', except if BODY is empty and all the bindings
are non-nil, then the result is non-nil." are non-nil, then the result is non-nil."
(declare (indent 1) (declare (indent 1)
@ -157,22 +157,20 @@ are non-nil, then the result is non-nil."
`(let* () ,@(or body '(t)))))) `(let* () ,@(or body '(t))))))
(defmacro if-let (spec then &rest else) (defmacro if-let (spec then &rest else)
"Bind variables according to SPEC and eval THEN or ELSE. "Bind variables according to SPEC and evaluate THEN or ELSE.
Each binding is evaluated in turn, and evaluation stops if a Evaluate each binding in turn, stopping if a binding value is nil.
binding value is nil. If all are non-nil, the value of THEN is If all are non-nil return the value of THEN, otherwise the last form in ELSE.
returned, or the last form in ELSE is returned.
Each element of SPEC is a list (SYMBOL VALUEFORM) which binds Each element of SPEC is a list (SYMBOL VALUEFORM) that binds
SYMBOL to the value of VALUEFORM. An element can additionally be SYMBOL to the value of VALUEFORM. An element can additionally be
of the form (VALUEFORM), which is evaluated and checked for nil; of the form (VALUEFORM), which is evaluated and checked for nil;
i.e. SYMBOL can be omitted if only the test result is of i.e. SYMBOL can be omitted if only the test result is of
interest. It can also be of the form SYMBOL, then the binding of interest. It can also be of the form SYMBOL, then the binding of
SYMBOL is checked for nil. SYMBOL is checked for nil.
As a special case, a SPEC of the form \(SYMBOL SOMETHING) is As a special case, interprets a SPEC of the form \(SYMBOL SOMETHING)
interpreted like \((SYMBOL SOMETHING)). This exists for backward like \((SYMBOL SOMETHING)). This exists for backward compatibility
compatibility with the old syntax that accepted only one with an old syntax that accepted only one binding."
binding."
(declare (indent 2) (declare (indent 2)
(debug ([&or (&rest [&or symbolp (symbolp form) (form)]) (debug ([&or (&rest [&or symbolp (symbolp form) (form)])
(symbolp form)] (symbolp form)]
@ -184,10 +182,9 @@ binding."
(list 'if-let* spec then (macroexp-progn else))) (list 'if-let* spec then (macroexp-progn else)))
(defmacro when-let (spec &rest body) (defmacro when-let (spec &rest body)
"Bind variables according to SPEC and conditionally eval BODY. "Bind variables according to SPEC and conditionally evaluate BODY.
Each binding is evaluated in turn, and evaluation stops if a Evaluate each binding in turn, stopping if a binding value is nil.
binding value is nil. If all are non-nil, the value of the last If all are non-nil, return the value of the last form in BODY.
form in BODY is returned.
The variable list SPEC is the same as in `if-let'." The variable list SPEC is the same as in `if-let'."
(declare (indent 1) (debug if-let)) (declare (indent 1) (debug if-let))