C-u 6 C-u 2
Documentation for universal-argument (emphasis mine):
Begin a numeric argument for the following command.
Digits or minus sign following C-u make up the numeric argument.
C-u following the digits or minus sign ends the argument.
C-u without digits or minus sign provides 4 as argument.
Repeating C-u without digits or minus sign
Hard to believe that people described this here without also giving you links to Emacs's own descriptions of this:
In the Emacs manual, node Arguments.
In the Elisp manual, node Prefix Command Arguments.
"Ask Emacs!": C-h i, choose a manual, i prefix argument RET.
In a nutshell, though this is said well enough by other answers here, and is described in ...
When raw prefix Interactive Code "P" is used, the argument is passed on as it is whereas "p" converts the arg to a number.
After evaluating the below elisp, try out C-u M-x my/fn-with-num-arg and then C-u M-x my/fn-with-raw-arg to see the difference because C-u passes a list argument (4).
(defun my/debug-fn (arg)
(if (numberp arg)
Sure. Use the raw prefix argument instead:
(defun my-prefix-test (arg)
((consp arg) (message "Prefix argument"))
((numberp arg) (message "Numeric argument"))
((eq '- arg) (message "Negative argument"))
((not arg) (message "No argument"))))
As you can see, current-prefix-arg can be a list, a number, - or nil.
According to shell's interactive form, as long as current-prefix-arg is non-nil, shell will ask user a buffer to use, so you can set current-prefix-arg to non-nil (4 is used in following as an example):
(let ((current-prefix-arg 4))
or simulate executing shell with a prefix 4 (M-4 M-x shell):
(execute-extended-command 4 "...
Leave the C-u off and check the binding for C-SPC (or whatever you're interested in). The universal argument (the C-u) is often used to make commands do different things. However, the docstring of the command will (or at least should) explain what the command does when preceded by universal arguments.
"How do you get the function bound to a keymap starting with C-u where it acts differently from an ordinary argument"?
C-u C-SPC and C-SPC will run the same function, just with different arguments.
You'll need to read the documentation or the source code to figure out exactly what the difference are.
Just to add a bit more detail to @kaushalmodi's answer (and useful test case):
The raw argument lets you distinguish between arguments provided with universal-argument and digit-argument.
With a numeric prefix arg there is no way to distinguish the universal argument C-u from a prefix arg of 4 (i.e. C-4). With the raw argument these are different: (4) vs ...
From the documentation of org-time-stamp:
With two universal prefix arguments, insert an active timestamp
with the current time without prompting the user.
So eval the below:
(org-time-stamp '(16) t)
'(4) - one prefix arg (4)
'(16) - two prefix args (4 * 4)
'(64) - three prefix args (4 * 4 * 4)
To read more about the universal arguments and ...
Assuming you only want to understand arguments given using only C-u, you can use a base-four logarithm:
(defun tmp:how-many (arg)
(when (consp arg)
(log (car arg) 4))))
Note that such a function is doomed to fail if a sequence like C-3 M-x tmp:test is used; the only appropriate response to such usage is to signal an error or return nil,...
Here's a more elegant way of doing it:
(defun foo (arg)
(list (if (consp current-prefix-arg)
(read-number "Number: ")
(message "prefix = %0d" arg))
current-prefix-arg holds the value you'd get from (interactive "P"). You can convert it to what (interactive "p") would ...
I will assume that you want to distinguish only uses of a plain prefix arg, e.g., C-u, C-u C-u, C-u C-u C-u, etc., and not uses of a numeric prefix arg, e.g., C-u 23, C-9, C-- 5.
Test both, in order:
Whether the value of current-prefix-arg is a cons, using consp. If not, then a plain prefix arg was not used.
The prefix-numeric-value of current-prefix-arg, ...
There is a common convention that a numeric prefix argument means “do it this many times”. If a command follows this convention, a prefix argument of 0 is useless. However, not all commands follow this convention or the other common convention of having two behaviors, one with no argument and one with a prefix argument other than 1.
For example, save-buffer ...
C-u C-SPC is not bound to a single key sequence. C-u is bound to universal-argument, and C-SPC is bound to set-mark-command. If you consult the doc for each of those you will get the answer to your question.
C-u provides a prefix argument for the following command, in this case for command set-mark-command. Consulting the doc for set-mark-command tells you ...
I think the only relevant key-binding to search is: C-x C-e which for me is bound to eval-last-sexp. C-0 and C-u 0 are prefix args that are passed to the function that C-x C-e is bound to; they don't change the function that is run.
To see what C-x C-e is bound to, type C-h k C-x C-e.
You can use this command to
There is a subtle distinction between C-u C-u C-u Tab and C-u 64 Tab. When you use only the C-u key, without using digits (i.e., 64), what actually gets passed to the org-cycle function (which is what Tab calls here) is a list: (64). If you use C-u 64 Tab, the argument passed to org-cycle is the integer 64.
It's up to the author of a function to decide how ...
Try the below snippet.. it uses call-interactively. So the arguments to the wrapper function will be passed on to the inner functions and then the interactive forms in those functions should do their job.
(defun my-mark-or-expand-dwim ()
"Set the mark or if mark already set call expand-region."
(if (or (use-region-p)
You cannot refer to SCOPE within the interactive form, because it is that form that defines SCOPE.
What you can do is use let to save the result of read-char-choice and then test that in the rest of the interactive spec.
(defun tmp:interactive (&optional scope pos-style)
"POS-STYLE has no effect when SCOPE is `directory'."
Optional arguments don't magically get a value when you use C-u unless you tell Emacs to do that.
Have a read of C-hf interactive (see options "p" and "P" in particular), and then see C-hig (elisp) Prefix Command Arguments.
Your question title doesn't match the body text?
If you want to "repeat a number" (singular), nanny's answer has you covered.
If (as per the title) you want to "repeat a list of numbers", I would use a keyboard macro. e.g.:
<f3> 12345 C-u6<f4>
describe-key is bound to C-h k.
If you want to know the function bound to C-u C-c .,
you should consider that C-u is a prefix to C-c .
and use just C-h k C-c ..
In this case, C-h k C-c . tells you that C-c . runs the command org-time-stamp and it also tells you what it does when called with a prefix argument:
If the user specifies a time like HH:MM or ...
@gilles and @npostavs have given use cases. To summarize what they said:
When you're already using C- or M- for part of a key sequence, it can be easier to specify a zero prefix arg using C-0 or M-0 than using, say, C-u 0.
A zero numeric prefix arg can have a specific (not necessarily numeric) meaning for a given command. @Gilles mentioned save-buffer, ...
Use C-uC-y to to interactively pass a listp arg to yank.
yank uses (interactive "P") which means the prefix argument is passed in raw form.
When a prefix arg is supplied via one or more C-u presses (only), the raw form of the argument is a list: (4) or (16) or (64), etc...
(And similarly for the - argument, which is also tested for explicitly in this ...
Let's explain the different code bits of your question (I'm reusing some of what I said in my comments).
What we find in the helm source definition is:
(dolist (elem extended-command-history)
(push (intern elem) cmds))
This builds a list of symbols. Each element of extended-command-history is a string which is transformed into ...
A list of all commands "that take prefix arguments" means a list of all commands.
If you instead mean a list of only those commands whose doc mentions prefix-argument behavior then you need to search command doc strings.
An easy way to do this is to use command apropos-documentation, which is bound to C-h d. Give it the regexp prefix[- ]+arg, for example.
Here is one way to get the functions that mention prefix in the doc string. This saves the output to a file
(loop for cmd-name in smex-ido-cache
(let* ((cmd (intern cmd-name))
(doc (documentation cmd)))
(when (and doc (string-match "prefix" doc))
(format "** %s\n\n%s\n\...