4

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 (image) file and select it. That is nice.

I am not able to ask via C-h k for what C-u C-c C-l points to because it shows me the answer only for C-u.

I am a bit confused here. What happens here and what is the difference? And how can I ask C-h k for C-u C-c C-l myself?

2 Answers 2

7

Disclaimer

I couldn't find a resource providing a good and understandable explanation about prefix arguments for new Emacs users. So I am a newbie and my explanation may not be the best.

Prefix argument concept

Emacs has the concept of prefix arguments to commands. The command loop looks for prefix arguments and arranges to pass them to the command.

E.g. the C-u C-c C-l can be described as C-u (the prefix argument) plus C-c C-l (the original key-binding). That is why you aren't able to ask for the keybinding with C-h k C-u C-c C-l (describe-key RET C-u C-c C-l). Do it without the C-u (i.e. just C-h k C-c C-l) and you find out that the key sequence C-c C-l is bound to org-insert-link. [1]

In the description of that function, the possible prefix arguments and how they modify the function's behaviour are described. E.g. the doc string above states:

With a ‘C-u’ prefix, prompts for a file to link to. The file name can be selected using completion. The path to the file will be relative to the current directory ...

In this example, you can also use two C-us as the prefix argument: C-u C-u C-c C-l. The doc string says:

With a ‘C-u C-u’ prefix, enforce an absolute path even if the file is in the current directory or below.

or you can even use three C-us as the prefix argument:

A ‘C-u C-u C-u’ prefix negates ‘org-link-keep-stored-after-insertion’.

The principle is that you have to ask for the documentation of the keybinding without any prefix arguments and look at the doc string of the command in order to figure out what various prefix arguments do.

[1] Note that you have to do that in an Org mode buffer: the keybinding C-c C-l does not generally exist in other keymaps.


N.B. Do not confuse prefix arguments as described above with prefix keys in a keymap. These two concepts are orthogonal.

4
  • 1
    Technically, C-u is not a prefix key: it's the universal prefix argument. In the above, C-c is a prefix key: it does not specify a complete command - you have to follow it with something else (C-l in this case) to specify the command completely. See Keys and Numeric arguments in the Emacs manual for more information.
    – NickD
    Commented Apr 8, 2022 at 14:19
  • Dear @NickD please use all the possibilities that StackExchange overs you and improve my answer with editing it directly and make it easier for other readers in the future.
    – buhtz
    Commented Apr 8, 2022 at 14:37
  • 1
    I'm planning to do that but it's going to take a little longer, so I wanted to raise the issue now - hence the comment.
    – NickD
    Commented Apr 8, 2022 at 14:44
  • 1
    See what you think about the edits.
    – NickD
    Commented Apr 9, 2022 at 15:51
3

Meta-answer: since the universal prefix argument (C-u) given once or more modifies a command's behavior, a properly-written command will thoroughly document each prefix argument. org-insert-link is properly written, and the sixth paragraph of its documentation provides the details you are looking for.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.