Questions tagged [prefix-argument]
The prefix-argument tag has no usage guidance.
52
questions
2
votes
0
answers
57
views
Composing Prefix Commands
There are several commands in Emacs that work as prefixes to other commands, changing the behavior of the next command in some way.
The most well-known example is the commands that set up the "...
6
votes
2
answers
375
views
Insert multiple minus ('-') characters using the universal argument (C-u)
I was manually creating a table in my source code's multiline comments
and inserting horizontal separators using - and =. E.g. C-u C-u C-u = as expected and inserts 64 =s at the point. But - is used ...
1
vote
1
answer
24
views
How to pass the prefix argument using a list in the `interactive` clause of a command definition?
How can I use prefix argument with list in the interactive clause? It is the more general way instead of Code Characters.
0
votes
1
answer
65
views
Getting prefix as argument
With this function, I get the error
test: Wrong type argument: stringp, 2
Is it good to pass prefix this way? Thought that the argument prefix would be filled up with the prefix value.
(defun test (...
0
votes
1
answer
340
views
Using current prefix argument value
I am doing a test with the current prefix argument to perform different tasks depending on the value of the current prefix argument.
I have a few questions.
Does (interactive "P") require ...
2
votes
2
answers
274
views
Can there be two prefix arguments?
I am very confused by the definitions of define-skeleton and skeleton-proxy-new in skeleton.el in the emacs source (version 28.1).
The command generated by the define-skeleton macro has the ...
1
vote
1
answer
120
views
How can I get the name of the file on the current Dired line?
I'm running emacs on WSL.
The following function launches the binary file marked in dired:
(defun wsl/execute ()
"execute file at point in dired"
(interactive)
(dired-do-shell-command
...
2
votes
1
answer
81
views
How to define key-combinations involving multiple `C-u`s
I wanted to define a short key combination for preview all latex fragments in a org file. Per this answer:
To preview all latex fragments in the buffer pass C-u twice before
calling org-latex-preview....
4
votes
2
answers
405
views
What is the difference between `C-u C-c C-l` and `C-c C-l`?
C-c C-l points to org-insert-link. In the minibuffer I am ask for a link type, link url and description.
But C-u C-c C-l shows me dired-like folder structure in the minibuffer and I can navigate to an ...
3
votes
2
answers
211
views
Are the Control & Meta "digit argument" bindings duplicates?
As far as I can tell the Meta and Control digit-argument bindings (C-1, C-2, C-3, M-1, M-2, M-3) are duplicates.
There are so few single-modifier, single-key bindings available, it seems like a ...
0
votes
0
answers
97
views
How to define absolute directory paths and use them as file prefixes in org files
I need to represent absolute paths to several directories by some constant names to use them as prefixes in org mode for a number of files contained in each of these directories.
For instance they ...
4
votes
1
answer
45
views
Using a number in register as prefix argument
How can I use a number in a register after C-u ?
For example my register looks like 1: 24, and I want to do C-u 24 x.
2
votes
1
answer
202
views
How can I pass an expression to a prefix argument?
Sometimes it would be useful to be able to pass an expression to a prefix argument, for example
c-u 3*4 c-n
If I try the command above though it will print three asterisks followed by the '4' ...
0
votes
0
answers
32
views
Behavior of universal-argument (C-u) changed between org 9.1.9 and org 9.4?
Running org version 9.1.9, when invoking C-u C-c C-t (org-agenda-todo) I get a completion list of my status values that I can select from.
In org version 9.4 the same call no longer allows me to ...
5
votes
2
answers
919
views
How to specify prefix argument in key binding
The description of C-x C-e mentions:
...Interactively, with a non '-' prefix argument, print output into current buffer.
I understand this to mean this logic is triggered when I issue C-u C-x C-e, ...
3
votes
1
answer
283
views
Assign a function with universal argument to a key (org-timer-start)
I would like to assing the function org-timer-start with a univeral argument (Ctrl-u) to its own key.
I read here, that one should look into the source code of a function to find out how to pass a ...
6
votes
1
answer
278
views
How to rebind "special meaning" of C-u to a different key?
Excerpt from GNU Emacs manual:
C-u alone has the special meaning of “four times”:
it multiplies the argument for the next command by four.
C-u C-u multiplies it by sixteen.
Thus, C-u C-u C-f moves ...
0
votes
1
answer
38
views
Treat initial numbers as argument to functions in minor mode
Is it possible to treat typed numbers similar to universal argument C-u 10 C-n, but make it so that there is no need to type C-u in a minor mode? So only 10 C-n would be needed to move 10 lines down ...
4
votes
3
answers
608
views
Use cases for M-0 & C-0?
The purpose of digit-argument and how to use them is described in Emacs manual.
Also read a question that asks how to disable them.
Even though have not disabled them, I have changed M-1, M-2, M-3 '...
1
vote
1
answer
85
views
How to write a command which uses the prefix argument AND some strings
I want to write a command which uses a prefix argument and reads some strings.
I know both parts individually:
(defun xtest(arg)
(interactive "P")
...
reads the prefix arg.
(defun xtest(t1 ...
4
votes
1
answer
279
views
How to bind 'C-u M-x shell' to 'C-c s'? [duplicate]
I would like to define the keybinding C-c s which should start a new shell in the current directory (so C-c s should behave like C-u M-x shell). I know how to define a keybinding based on a function (...
0
votes
1
answer
58
views
Given a keyboard command, how do you find the interactive function? [duplicate]
I have a key sequence for C-u C-c . How would I find the function that's bound to it. I thought it was describe-key but that doesn't seem to work.
Cheers
1
vote
0
answers
862
views
What does C-u mean in sequence "C-u M-x"
I learnt that C-u default is to repeat 4 times.
For example:
C-u t is input tttt
However, when I type C-u M-x, it prompts a function list
What does invoking C-u mean here?
2
votes
1
answer
381
views
how to implement a numeric prefix argument in emacs
When I press "d", this loop runs 52 times.
How can I adjust this elisp so that, I can specify a number
instead of harcoding 52.
I guess I'm trying to do something like " C-u -1 C-x ^" mentioned at ...
2
votes
1
answer
341
views
Find out about arguments passed to functions
When I press C-h k C-SPC, Emacs shows me:
C-SPC runs the command set-mark-command (found in global-map), which
is an interactive compiled Lisp function.
It is bound to C-@, C-SPC.
(set-...
0
votes
1
answer
302
views
"C-3" vs "C-u 3-" in spacemacs
I'am using spacemacs and I was reading this 5.2.1 TODO keywords as workflow in the org manual and it says that to set a specific state right way the sequence of keys C-3 C-c C-t can be used.
If I ...
0
votes
1
answer
41
views
key binding for disabling column-marker
In my .emacs I have the following:
(progn ;
(defvar my-keys-minor-mode-map
(let ((map (make-sparse-keymap)))
; other bindings ..
(define-key map (kbd "C-c c" ) 'column-marker-3)
...
3
votes
1
answer
110
views
What's the difference between C-u C-u C-u <Command> and C-u 64 <Command>?
In org-mode, C-u C-u C-u Tab expands all trees. When I wanted to check what it's bound to, I wasn't able to do that using C-h k as it quickly told me what C-u is bound to. From experiments, I know ...
0
votes
1
answer
63
views
What function are associated with these expression evaluation commands in buffers?
What are the function names for these two bindings?
C-o C-x C-e - evaluate expression before cursur and display limited length result in echo area
C-u 0 C-x C-e - evaluate expression before cursor ...
1
vote
2
answers
157
views
how does optional argument `ALLOW-EXTEND` in `mark-word` work?
I am switching from VIM to Emacs for just a couple weeks and trying to write some Elisp. Having difficulties to adapt, I am exploring different options to do marking and reached this function.
(defun ...
3
votes
0
answers
126
views
Replace formula by computed value
I'd like to select a simple formula like 17+5 and replace that by the computed result, 22 in this case. And I need this to work during keyboard macro execution, to quickly process large portions of my ...
2
votes
2
answers
245
views
Finding possible prefix arguments
Emacs is aweseome but sometimes it feels it's too smart for its own good. You may feel you learned everything there's to know about a function and then someone tells you to try a prefix argument and ...
8
votes
1
answer
449
views
How to describe a key sequence that starts with `C-u`?
I am trying to use C-h k to describe the function to which a key is bound. But when I use it with a key chord like C-u C-e C-x it retrieves the documentation for C-u before I can finish typing the ...
0
votes
1
answer
108
views
Differentiating between raw prefix arguments
Is there a way to differentiate between different numbers of raw prefix arguments (e.g. C-u vs. C-u C-u) aside from checking whether the argument is (4), (16), etc.?
This seems to be what packages ...
13
votes
1
answer
2k
views
How to apply `call-interactively` to an interactive command that accepts the universal argument?
I've read the documentation on how to make interactive calls from within Elisp, but I still can't figure out how to pass the universal argument when using call-interactively on a command that ...
2
votes
2
answers
620
views
Compile from parent directory in Emacs
I'm trying to map F5 to compile from a parent directory of the current buffer.
Emacs compile-command find makefile in superior directory
provides an excellent answer to achieve this:
(defun compile-...
8
votes
1
answer
631
views
How to pass a prefix argument to helm-m-x?
I have read the prefix has to be added after running helm-m-x, but I don't know how to do it.
For example I want to pass an argument to shell. When I run helm-m-x and then C-u I see in the mode-line [...
4
votes
2
answers
504
views
How to initiate a prompt for user input based on the prefix argument?
The below dummy foo describes how I need the prefix variable setting to work.
I'd like the read-number prompt to show up only if the user entered C-u as prefix. In all other cases, the prefix will be ...
4
votes
1
answer
182
views
Distinguish C-u <key> from C-u 4 <key>
I know that C-u sends the prefix 4. Is there any way to make C-u <key> a special case of a command, while still allowing C-u 4 <key>?
1
vote
2
answers
181
views
Getting latest command from function, but function exceeds "max-lisp-eval-depth"
This defines the Helm-source for Emacs commands history.
(defvar helm-source-emacs-commands-history
(helm-build-sync-source "Emacs commands history"
:candidates (lambda ()
...
1
vote
2
answers
129
views
Obtain the raw prefix arg and its numeric value, and pass them to different commands
As I'm running out of easy key bindings I'm trying to overload C-SPC to either call set-mark-command or er/expand-region depending on if I have moved since I set the mark. However the two functions ...
12
votes
3
answers
3k
views
What is a raw prefix argument? (capital P in interactive)
And what can they be used for?
(interactive "p") takes a numerical argument from the universal argument right? And the universal argument is just an int either way, so what does capital (interactive "...
6
votes
3
answers
757
views
How to find out which function is bound to C-u C-SPC?
C-u C-SPC is used to
Move point to where the mark was, and restore the mark from the ring
of former marks.
When trying to get the function bound to C-u C-SPC with describe-key it just stops ...
8
votes
3
answers
263
views
Swap default behavior of command with C-u behavior
Many Emacs commands alter their behavior when called with one or more C-u prefixes. In some cases the default behavior of a command is less useful to me than the behavior I get when prefixing it with ...
6
votes
2
answers
2k
views
How to insert inactive [timestamp] via function?
C-u C-c ! generates a time stamp like [2015-05-04 Mon 17:13]
I would like to assign a shortcut (e.g F1) to this action.
So far I have:
(defun my/timenow (&optional arg)
(interactive)
(let (...
1
vote
1
answer
284
views
how to assign a list or string to current-prefix-arg?
current-prefix-arg's
help doc says, the variable can contain a list (or) number (or) minus symbol. I mostly set a number as the prefix-arg by keypress, C-[1-9].
But how can i assign a list or ...
0
votes
1
answer
305
views
universal argument can not work in this function?
I made a function in Windows Emacs like:
(defun explorer (&optional tex)
(interactive)
(let* ((current-path (file-name-directory (buffer-file-name)))
(file-path-at-point
(...
15
votes
2
answers
1k
views
How to use a numeric prefix to repeat insertion of a digit?
Suppose I want to type '222222' in emacs, how do I use the numeric prefix idiom to achieve this? A naive guess would be 'C-u 6 2' but emacs interprets this as a numeric prefix of 62 and waits for the ...
0
votes
1
answer
1k
views
post-command-hook and prefix argument
I have a non-interactive function F to do post processing after each command. F is buffer locally hooked to post-command-hook.
Whenever F is hooked the prefix argument is eaten and the next command ...
0
votes
1
answer
143
views
How to interactivelly pass a `listp arg` to `yank`
Is it possible to interactively pass an argument that matches listp to the function yank so that current-kill receives an argument of 0? If so, how please can that be achieved?
Background:
I am ...