From: "Drew Adams" <drew.adams@oracle.com>
To: "'Andreas Röhler'" <andreas.roehler@easy-emacs.de>,
"'Daniel Colascione'" <dan.colascione@gmail.com>
Cc: 'Emacs developers' <emacs-devel@gnu.org>
Subject: RE: more than one prefix argument
Date: Tue, 26 Jul 2011 13:57:52 -0700 [thread overview]
Message-ID: <C3BE783C11814951997D95A15A6BAF47@us.oracle.com> (raw)
In-Reply-To: <4E2F2546.3010704@easy-emacs.de>
> 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.
next prev parent reply other threads:[~2011-07-26 20:57 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-26 19:59 more than one prefix argument Andreas Röhler
2011-07-26 20:10 ` Daniel Colascione
2011-07-26 20:36 ` Andreas Röhler
2011-07-26 20:57 ` Drew Adams [this message]
2011-07-26 20:36 ` Drew Adams
2011-07-27 6:25 ` Andreas Röhler
2011-07-27 9:25 ` Tim Cross
2011-07-27 9:37 ` Andreas Röhler
2011-07-27 9:48 ` Tim Cross
2011-07-27 10:21 ` Andreas Röhler
2011-07-27 11:21 ` Andreas Schwab
2011-07-27 11:46 ` Andreas Röhler
2011-07-27 12:39 ` Andreas Schwab
2011-07-27 12:51 ` Tim Cross
2011-07-27 12:46 ` Tim Cross
2011-07-27 15:09 ` Drew Adams
2011-07-27 9:38 ` Tim Cross
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=C3BE783C11814951997D95A15A6BAF47@us.oracle.com \
--to=drew.adams@oracle.com \
--cc=andreas.roehler@easy-emacs.de \
--cc=dan.colascione@gmail.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.