views:

70

answers:

1

Hi, I'm trying to use C-h c in emacs to figure out what a key combination is bound to. The combination is C-u C-c C-q, which realigns tags in org-mode. However, Emacs just tries to look up C-u C-c and then fails. What am I doing wrong? I realize I could easily look at the orgmode source or something to figure this out, but for future reference what would I do to figure out what function something like this is bound to?

Edit: OK, so it's actually C-u followed by C-c C-q, and according to emacs this is what that combination is bound to:

(org-set-tags-command &optional arg just-align)

Call the set-tags command for the current entry.

So what exactly does it mean to give this command the argument 4?

Oh, just to give an explanation: I'm trying to start learning emacs-lisp and customization and one of the things I wanted to do was to have this command added to the before-save-hook so that when I save an org file, the tags get automatically aligned.

Final edit: I figured out why this command behaves as it does; given the prefix argument it changes its behavior. How can I set the prefix argument when calling the function in elisp?

+4  A: 

It's not a general problem with combinations that are three keys long: For example, C-h c ESC ESC ESC (keyboard-escape-quit) or C-h c C-x r t (string-rectangle) both work fine.

When I try C-h c C-u C-c C-q in org-mode, the command interrupts after C-u and shows:

C-u runs the command universal-argument

in the minibuffer, which is correct. So, in fact, "C-u C-c C-q" is not a command, it's the command "C-c C-q" (org-table-wrap-region) started with an additional argument (4 -- see C-h k C-u for an explanation).

Heinzi
That's what I was thinking, but this is very confusing to me. I got this command from the orgmode reference card, and it is described as "Realign tags in all headings" and the binding for `C-c C-q` is `(org-defkey org-mode-map "\C-c\C-q" 'org-set-tags-command)`although I'm guessing you just made a typo when you said `org-table-wrap-region`.
Ibrahim
Oh, I guess its' more of this:>For some commands, just C-u by itself serves as a flag>which is different in effect from any particular numeric argument.Hmm... I guess I'll dive into the source then.
Ibrahim
Well, here it says: <code>C-c C-q runs the command org-table-wrap-region</code>; maybe I'm just running a different version of org-mode (6.05) here. I'm not really familiar with org-mode, so I guess I cannot explain this...
Heinzi
Oh, maybe it's just because it's a different version. Thanks for your help anyway, you basically told me enough to almost do what I wanted. I just need to figure out how to call a function with a prefix argument in elisp.
Ibrahim
Try passing it as a "normal" argument: (org-set-tags-command 4) should do the trick.
Heinzi