[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Most Emacs commands can use a prefix argument, a number
specified before the command itself. (Don't confuse prefix arguments
with prefix keys.) The prefix argument is at all times represented by a
value, which may be nil
, meaning there is currently no prefix
argument. Each command may use the prefix argument or ignore it.
There are two representations of the prefix argument: raw and numeric. The editor command loop uses the raw representation internally, and so do the Lisp variables that store the information, but commands can request either representation.
Here are the possible values of a raw prefix argument:
nil
, meaning there is no prefix argument. Its numeric value is
1, but numerous commands make a distinction between nil
and the
integer 1.
-
. This indicates that M-- or C-u - was
typed, without following digits. The equivalent numeric value is
-1, but some commands make a distinction between the integer
-1 and the symbol -
.
We illustrate these possibilities by calling the following function with various prefixes:
(defun display-prefix (arg) "Display the value of the raw prefix arg." (interactive "P") (message "%s" arg)) |
Here are the results of calling display-prefix
with various
raw prefix arguments:
M-x display-prefix -| nil C-u M-x display-prefix -| (4) C-u C-u M-x display-prefix -| (16) C-u 3 M-x display-prefix -| 3 M-3 M-x display-prefix -| 3 ; (Same as |
Emacs uses two variables to store the prefix argument:
prefix-arg
and current-prefix-arg
. Commands such as
universal-argument
that set up prefix arguments for other
commands store them in prefix-arg
. In contrast,
current-prefix-arg
conveys the prefix argument to the current
command, so setting it has no effect on the prefix arguments for future
commands.
Normally, commands specify which representation to use for the prefix
argument, either numeric or raw, in the interactive
declaration.
(See section 21.2.1 Using interactive
.) Alternatively, functions may look at the
value of the prefix argument directly in the variable
current-prefix-arg
, but this is less clean.
nil
, the value 1 is returned; if it is -
, the
value -1 is returned; if it is a number, that number is returned;
if it is a list, the CAR of that list (which should be a number) is
returned.
(interactive "P")
.
universal-argument
that specify prefix arguments for the following command work by setting
this variable.
The following commands exist to set up prefix arguments for the following command. Do not call them for any other reason.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |