Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [prefix-argument]

The tag has no usage guidance.

4
votes
1answer
55 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
1answer
36 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
0
votes
0answers
79 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
1answer
45 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
1answer
40 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
1answer
116 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
1answer
21 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
1answer
68 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
1answer
51 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
2answers
69 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 ...
2
votes
0answers
47 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
2answers
127 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 ...
7
votes
1answer
256 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
1answer
89 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 ...
7
votes
1answer
1k 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 ...
1
vote
1answer
158 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
1answer
360 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 [...
3
votes
2answers
228 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
1answer
157 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
2answers
131 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
2answers
94 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 ...
9
votes
3answers
1k 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
3answers
505 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 ...
7
votes
3answers
162 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 ...
2
votes
1answer
612 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
1answer
110 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
1answer
182 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 (...
9
votes
2answers
562 views

How do I use a numeric prefix to repeat a list of numbers?

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
1answer
445 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
1answer
98 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 ...
3
votes
1answer
169 views

Can I accept a prefix argument based on another argument within an `(interactive …)` form?

(defun tmp:interactive (&optional scope pos-style) "POS-STYLE has no effect when SCOPE is `directory'." (interactive (list (cdr (assoc (read-char-choice "Copy (f)ull ...
5
votes
2answers
226 views

Is there an easy way to detect how many `C-u`s a command was given?

I have made the following function to count how many C-u prefixes a command was given (assuming it is called interactively), but I feel this is a common-enough problem that there should be a built-in ...