[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: more than one prefix argument
From: |
Drew Adams |
Subject: |
RE: more than one prefix argument |
Date: |
Tue, 26 Jul 2011 13:57:52 -0700 |
> Indeed: (prefix-numeric-value nil) -->1
> But does this make sense in a lisp-environement?
Dunno what that means. nil is not 1. But (foo nil) might well be 1. (length
nil) is 0, but that doesn't mean that nil is zero.
`prefix-numeric-value' is just a function that returns a number (always). If
its arg is nil then it returns 1. Nothing more to be said about it, really.
> Booleans treat nil and 1 different:
> (when 1 (message "%s" "1"))-->1
> (when nil (message "%s" "1"))-->nil
Yes. `prefix-numeric-value' is not a Boolean function. The numeric value of
the prefix arg is just that: a numeric value. It is a number, never nil, so it
is useless as a (Lisp) Boolean value: it is always non-nil (true).
(Well, you could decide that some particular number or set of numbers
represented false, and then test that way, but you get the idea: it will not
return `nil'.)
The _raw_ value of a prefix arg can be nil, so you can use that as a Lisp
Boolean value (nil vs non-nil). The raw value distinguishes presence and
absence: whether or not the user specified a prefix argument when invoking the
command.
It also distinguishes other things, however. The raw arg is richer than its
reduction to a numeric value. The raw prefix arg tells you pretty much what the
user did - whether s?he hit `C-u C-u C-u' or `C-u 3 2 9' or `M--' etc.
If you want to let the user distinguish several cases using a prefix arg, then
you want to do it using the raw arg. You can test whether the arg is a cons or
nil or `-'; you can test its numeric value; etc. And you can test it in
different ways at the same time: both a cons and numeric value = 16, etc.
- more than one prefix argument, Andreas Röhler, 2011/07/26
- Re: more than one prefix argument, Daniel Colascione, 2011/07/26
- Re: more than one prefix argument, Andreas Röhler, 2011/07/26
- RE: more than one prefix argument,
Drew Adams <=
- RE: more than one prefix argument, Drew Adams, 2011/07/26
- Re: more than one prefix argument, Andreas Röhler, 2011/07/27
- Re: more than one prefix argument, Tim Cross, 2011/07/27
- Re: more than one prefix argument, Andreas Röhler, 2011/07/27
- Re: more than one prefix argument, Tim Cross, 2011/07/27
- Re: more than one prefix argument, Andreas Röhler, 2011/07/27
- Re: more than one prefix argument, Andreas Schwab, 2011/07/27
- Re: more than one prefix argument, Andreas Röhler, 2011/07/27
- Re: more than one prefix argument, Andreas Schwab, 2011/07/27
- Re: more than one prefix argument, Tim Cross, 2011/07/27