emacs-pretest-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: list-buffers-noselect: `when' should be `and'


From: Chris Moore
Subject: Re: list-buffers-noselect: `when' should be `and'
Date: Sun, 18 Feb 2007 00:29:52 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.93 (gnu/linux)

Stefan Monnier <address@hidden> writes:

>> `when' should be `and' in this code, for clarity. I don't think this
>> has an effect on functioning, but `when' should generally not be used
>> when its value is important, as in this case. Here, the return value
>> is an argument to function `buffer-list'.
>
> I disagree, so let's leave it.

If we're going to use the return value of 'when' in this manner, we
should document 'when' to state what its return value is (and the same
goes for 'unless' as well).  These changes are based on the
documentation for 'if':

Index: lisp/subr.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/subr.el,v
retrieving revision 1.546
diff -u -r1.546 subr.el
--- lisp/subr.el        9 Feb 2007 23:09:16 -0000       1.546
+++ lisp/subr.el        17 Feb 2007 23:28:34 -0000
@@ -99,12 +99,24 @@
              (list 'setq listname (list 'cdr listname)))))
 
 (defmacro when (cond &rest body)
-  "If COND yields non-nil, do BODY, else return nil."
+  "If COND yields non-nil, do BODY.
+Returns nil or the value of the last of the BODY's.
+If COND yields nil, the value is nil.
+If COND yields non-nil, and there are no BODY's, the value is nil.
+BODY... is zero or more expressions.
+
+\(fn COND BODY...)"
   (declare (indent 1) (debug t))
   (list 'if cond (cons 'progn body)))
 
 (defmacro unless (cond &rest body)
-  "If COND yields nil, do BODY, else return nil."
+  "If COND yields nil, do BODY.
+Returns nil or the value of the last of the BODY's.
+If COND yields non-nil, the value is nil.
+If COND yields nil, and there are no BODY's, the value is nil.
+BODY... is zero or more expressions.
+
+\(fn COND BODY...)"
   (declare (indent 1) (debug t))
   (cons 'if (cons cond (cons nil body))))
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]