[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Detect if Emacs is running in -nw mode
From: |
Rupert Swarbrick |
Subject: |
Re: Detect if Emacs is running in -nw mode |
Date: |
Sun, 30 Mar 2008 10:10:46 -0600 |
User-agent: |
Pan/0.132 (Waxed in Black) |
On Sun, 30 Mar 2008 16:45:57 +0200, Lennart Borgman (gmail) wrote:
> The documentation should be exact enough to show that. If not then it is
> a documentation bug.
>
> In this case it says "body forms", not "body form". A form is something
> inside a pair of (). So it is ok with several functions here.
>
> If it was not you could have used progn for example.
I'm not sure and if I'm wrong, Christian, please correct me, but:
I think the problem is that Christian doesn't know what "body" means. In
lisp, a function is defined using something called a lambda list, so I
might define a function foo like:
(defun foo (arg1 arg2 arg3) (do-some-stuff))
In this case arg1, arg2 and arg3 are three different arguments, so we'd
call foo like this
(foo 1 2 3)
Great. However, if you want to write a useful unless function/macro, you
want to allow any number of elements in the list - a bit like varargs do
in C, if you know about that.
Anyhow, you write something like
(defun bar (arg1 &rest others) (do-some-stuff))
or (pretty much equivalently)
(defun bar (arg1 &body others) (do-some-stuff))
For bar, arg1 is just a normal argument. But others is a bit magic:
(bar 1 2 3 4 5 6)
sets arg1 to 1 and others to (2 3 4 5 6) (a list). Now, unless is
actually a macro and the bit it does next depends on a whole new can of
worms based on macro expansion and ,@ but I'm not going to go into that.
The main point however is that the documentation says:
> --
> |unless is a Lisp macro in `subr'.
> |(unless COND &rest BODY)
> |
> |If COND yields nil, do BODY, else return nil.
> --
So the &rest bit means that body can contain as much as you like. FWIW,
unless executes BODY in a progn, so for example
(unless (function-returning-nil) 1 2 3)
evaluates to 3. Not that that matters in this situation.
Phew. That was more than I intended to write! Hope it makes things a
little clearer.
Rupert
- Re: Detect if Emacs is running in -nw mode, (continued)
- Message not available
- Re: Detect if Emacs is running in -nw mode, Will Parsons, 2008/03/29
- Re: Detect if Emacs is running in -nw mode, Christian Herenz, 2008/03/29
- Re: Detect if Emacs is running in -nw mode, BVK, 2008/03/29
- Re: Detect if Emacs is running in -nw mode, Rupert Swarbrick, 2008/03/30
- Re: Detect if Emacs is running in -nw mode, Christian Herenz, 2008/03/30
- Re: Detect if Emacs is running in -nw mode, Lennart Borgman (gmail), 2008/03/30
- Message not available
- Re: Detect if Emacs is running in -nw mode, Christian Herenz, 2008/03/30
- Re: Detect if Emacs is running in -nw mode, Lennart Borgman (gmail), 2008/03/30
- Re: Detect if Emacs is running in -nw mode, Peter Dyballa, 2008/03/30
- Message not available
- Re: Detect if Emacs is running in -nw mode, Christian Herenz, 2008/03/30
- Message not available
- Re: Detect if Emacs is running in -nw mode,
Rupert Swarbrick <=
- Re: Detect if Emacs is running in -nw mode, Christian Herenz, 2008/03/30
- Re: Detect if Emacs is running in -nw mode, Tim X, 2008/03/31
- Re: Detect if Emacs is running in -nw mode, Christian Herenz, 2008/03/31
- Re: Detect if Emacs is running in -nw mode, Nuno J. Silva, 2008/03/31
- Re: Detect if Emacs is running in -nw mode, Barry Margolin, 2008/03/30
- Re: Detect if Emacs is running in -nw mode, Christian Herenz, 2008/03/31