Enter Ch f when RET and you will see the documentation:
when - Lisp macro in subr.el
(when COND BODY...)
When COND gives non nil , eval BODY forms sequentially and returns the value of the latter, or nil if none exist.
You can see how this is implemented if you macro-expand it:
ELISP> (macroexpand '(when cond body1 body2 body3)) (if cond (progn body1 body2 body3))
You should use when instead of if in case you don't have an else clause. It looks better, and it gives the reader a hint that there is no βyetβ sentence. If you have an else clause but no then clause, you can write unless .
source share