Next: Recursive Editing, Previous: Quitting, Up: Command Loop [Contents][Index]
Most SXEmacs 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 asC-u 3
.) C-3 M-x display-prefix -| 3 ; (Same asC-u 3
.) C-u - M-x display-prefix -| - M-- M-x display-prefix -| - ; (Same asC-u -
.) C-- M-x display-prefix -| - ; (Same asC-u -
.) C-u - 7 M-x display-prefix -| -7 M-- 7 M-x display-prefix -| -7 ; (Same asC-u -7
.) C-- 7 M-x display-prefix -| -7 ; (Same asC-u -7
.)
SXEmacs 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 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.
This function returns the numeric meaning of a valid raw prefix argument
value, raw. The argument may be a symbol, a number, or a list.
If it is 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.
This variable holds the raw prefix argument for the current
command. Commands may examine it directly, but the usual way to access
it is with (interactive "P")
.
The value of this variable is the raw prefix argument for the next editing command. Commands that specify prefix arguments for the following command work by setting this variable.
Do not call the functions universal-argument
,
digit-argument
, or negative-argument
unless you intend to
let the user enter the prefix argument for the next command.
This command reads input and specifies a prefix argument for the following command. Don’t call this command yourself unless you know what you are doing.
This command adds to the prefix argument for the following command. The argument arg is the raw prefix argument as it was before this command; it is used to compute the updated prefix argument. Don’t call this command yourself unless you know what you are doing.
This command adds to the numeric argument for the next command. The argument arg is the raw prefix argument as it was before this command; its value is negated to form the new prefix argument. Don’t call this command yourself unless you know what you are doing.
Next: Recursive Editing, Previous: Quitting, Up: Command Loop [Contents][Index]