What function is C-c C-v bound to in org-mode? - org-mode

I am new to Emacs working through the Org-mode beginning at the basics tutorial.
The "Working with todo items" part of the tutorial uses a C-c C-v binding.
But C-c C-v is not working on my Spacemacs. And it is not listed in describe-bindings:
SPC h d b
pattern: C-c C-v
"Prefix Command" is a keyboard macro.
Macro: P r e f i x SPC C o 2*m a n d
Similar results in emacs mode:
C-z
C-h b
pattern: C-c C-v
"Prefix Command" is a keyboard macro.
Macro: P r e f i x SPC C o 2*m a n d
C-c C-v doesn't work in Spacemacs mode nor Emacs mode.
What function is C-c C-v supposed to be bound to?
Is "C-c C-v" deprecated or a typo?
Is there an on-line resource that lists all the default Emacs key bindings?
I am running Emacs 25.2.1 with Spacemacs on Linux.

It used to be bound to org-show-todo-tree, but the binding was changed back in 2010: C-c C-v is now a prefix key for various org-babel functions.
You can call org-show-todo-tree with M-x org-show-todo-tree RET or you can install your own binding to org-show-todo-tree (the function is still around); or you can use C-c / t which shows a sparse tree of TODO items in the current buffer. In this last case, C-c / is bound to org-sparse-tree which gives you a bunch of options: t selects the TODO case, but you might want to experiment with the other options.
EDIT: BTW, I found all this using some git commands in my clone of the org-mode git repo. I used
git log --oneline --grep='C-c C-v'
to find commits that mention that key combo. The actual commit was
commit 3d8b6de2ad00220e164f226fb0dde5ada831d21b
Author: Carsten Dominik
Date: Wed May 12 08:04:27 2010 +0200
Free up the `C-c C-v' key for Org Babel
TODO sparse trees are also accessible with `C-c / t'.
Isn't git wonderful?

Related

Browse definition in Coq-IDE

In the Isabelle proof assistant, one can click Ctrl+click on a term and the IDE redirects him to the relevant definition.
Can this be done with CoqIde? With Proof-General?
Yes, the features you mention in your post and in your comment (as an aside, feel free to edit your question to incorporate your comment) are possible in Proof-General and/or company-coq (an Emacs package gathering IDE extensions of Proof-General):
to see the content of a definition def (equivalent of Print def.): C-c C-a C-p def RET
to see the type of a definition def (equivalent of Check def.): C-c C-a C-c def RET
to see the type and related metadata of a definition def (equivalent of About def.): C-c C-a C-b def RET
to see all this in one go for the identifier under point (requires company-coq): C-c C-d
to be redirected to the location of the definition under point (requires company-coq): M-.
to make the definition under point show up without moving (requires company-coq): <C-down-mouse-1>
Reminders
Just to be self-contained, the Emacs keybindings C-c, M-., RET, <C-down-mouse-1> refer to Ctrl+c, Alt+., Return, and Ctrl+click (without releasing the mouse button).
Finally you can discover the list of bindings associated to the ambient mode by doing C-h m:
C-h k [describe-key] C-h m [describe-mode]:
C-h m runs the command describe-mode (found in global-map), which is
an interactive compiled Lisp function in ‘help.el’.
It is bound to C-h m, <f1> m, <help> m, <menu-bar> <help-menu>
<describe> <describe-mode>.
(describe-mode &optional BUFFER)
Display documentation of current major mode and minor modes.
A brief summary of the minor modes comes first, followed by the
major mode description. This is followed by detailed
descriptions of the minor modes, each on a separate page.
[…]

How to bind C-x SPC locally to gud mode in Emacs 25

Similar to How to change GUD breakpoint keybinding to the old one but I would like to bind CTRL+x followed by SPACE to be gud-break.
What I have working (well it is a hack; keep reading) is:
(define-key ctl-x-map " " 'gud-break)
but ctl-x-map is a global variable akin to the global map. And in fact, if I switch to another C++ buffer and type C-h k C-x SPC I get:
C-x SPC runs the command gud-break (found in global-map), which is an interactive compiled Lisp function.
It is bound to C-x SPC, C-x C-a C-b.
(gud-break ARG)
Set breakpoint at current line.
which means the global definition across all buffers is what was changed, which is not correct AFAIK.
Is there a way to "insert" or somehow affect the local key map for C-x, which I believe is gud-mode-map, because I want that binding to not be global for all C++ buffers. E.g., the global binding for CTRL+x followed by SPACE is rectangle-mark-mode.
Yes I realize the standard binding is C-x C-a C-b for gud-break, but that is asking for RSI.
Update #1
Since I need the local key map for gud-mode-map, this needs to be active only when I'm running a debugger. In my case, this is in C++ mode buffers, but my understanding is that gud-mode-map becomes active in those C++ mode buffers only during the debug session, and is removed from the key bindings when gud mode is finished.
Update #2
This did not work:
(define-key gud-mode-map [(control x ?\ )] 'gud-break) ;; <-- gave "Two bases given in one event" error too.
(define-key gud-mode-map (kbd "C-x SPC") 'gud-break) ;; <-- this does not work either.
Update #3
As an experiment, I commented out my define-key bindings in my hook I add to gud-gdb-mode-hook, reran gdb, then switched to the gud buffer (not the C++ source file) and typed C-h k C-x SPC I get this:
C-x SPC runs the command gud-break (found in gud-mode-map), which is
an interactive Lisp closure.
It is bound to <menu-bar> <debug> <break>, C-x SPC, C-c C-b, C-x C-a
C-b.
(gud-break ARG)
Set breakpoint at current line.
But then when I switch over to the C++ buffer that should also have the same bindings inserted temporarily (while gud mode is active), and then do the same thing I get this instead:
C-x SPC runs the command rectangle-mark-mode (found in global-map),
which is an interactive autoloaded compiled Lisp function in
'rect.el'.
It is bound to C-x SPC.
(rectangle-mark-mode &optional ARG)
Toggle the region as rectangular.
Activates the region if needed. Only lasts until the region is deactivated.
Switching back to the gud buffer, and typing C-h m shows this:
Debugger mode defined in 'gud.el':
Major mode for interacting with an inferior debugger process.
You start it up with one of the commands M-x gdb, M-x sdb, M-x dbx,
M-x perldb, M-x xdb, or M-x jdb. Each entry point finishes by executing a
hook; 'gdb-mode-hook', 'sdb-mode-hook', 'dbx-mode-hook',
'perldb-mode-hook', 'xdb-mode-hook', or 'jdb-mode-hook' respectively.
After startup, the following commands are available in both the GUD
interaction buffer and any source buffer GUD visits due to a breakpoint stop
or step operation:
C-x SPC sets a breakpoint at the current file and line. In the
GUD buffer, the current file and line are those of the last breakpoint or
step. In a source buffer, they are the buffer's file and current line.
...
Notice the reference to C-x SPC above. It is as if they intended to bind C-x SPC but it did not work, or something is preventing it from being bound properly in that buffer when gud mode is entered.
I'm not exactly clear on what you want. But if you only want to redefine the key C-x SPC when the gud-mode-map is active, then tell define-key you want to use that map: (define-key gud-mode-map ...).
I've chosen to give up on this altogether. using C-x SPC in the buffer is problematic anyhow. I noticed that the C-x C-a prefix that is used for the gud bindings are left in the C++ buffer even after gud finishes, so the gud mode is not cleaning up after itself anyhow.

emacs error: Key sequence M-x g starts with non-prefix key M-x

I have the following code in .emacs: (global-set-key (kbd "M-x g") 'gnus) to start Gnus with the keybinding M-x g. I obtain: error: Key sequence M-x g starts with non-prefix key M-x. How can I define keybindings starting with M-x? Is this a bad thing to do and should be avoided? I find it more intuitive since the "long version" is M-x gnus. Defining it as C-c g for example is no problem but then you start Gnus with C-c g and, for example, R via M-x R which is not very intuitive (in contrast to starting both via M-x + 1 letter
The key M-x is already bound to the command execute-extended-command, which then asks you to provide the name of a command to execute (in you case: gnus).
Since R is a command only one-character long, it looks like M-x R is a key sequence, but it's not: it's M-x followed by entering R in the minibuffer and you have to hit RET to validate your input.
In short:
you can not set key sequences beginning with M-x since this key is already bound to a command and is thus not a prefix (unlike C-c, which does nothing but wait for you to type another key, but should be reserved for bindings specific to the current modes).
the standard way to do things would be to continue starting gnus using M-x gnus or to rebind it to an entirely different key if you need to be very quick (you could for example use one of the F1-F12 keys)
if you really want to have a M-x + letter binding, you can define a one-letter alias to the command gnus, like this:
(defalias 'g 'gnus)

Convert Emacs macro into Elisp

Is there a way to convert an emacs macro into elisp, not like what M-x insert-kbd-macro does, the actual activity becoming elisp statements.
Thanks for your help.
Nope, sorry. There is no trivial way to convert an emacs macro into elisp.
Update: There's been some work on Emacs to start down this path. See this thread as a starting point. It's still not possible (June 2010), but there's activity.
The first reason I can think of is dealing with interactive commands and translating keystrokes into proper arguments for functions.
Think of the following sequence:
C-x b .em TAB RET
This begins the command to switch to a buffer, types three characters, uses TAB completion to complete it and RET to accept. The equivalent lisp for the end result (in an emacs session where the TAB completion is unique) is:
(switch-to-buffer ".emacs")
Thinking of completion, there are also interactions with expansion of all types (dabbrev, hippie-expand, etc.).
A starting point can be M-x edit-last-kbd-macro which (in my case) shows this:
;; Keyboard Macro Editor. Press C-c C-c to finish; press C-x k RET to cancel.
;; Original keys: C-x b .em <tab> RET
Command: last-kbd-macro
Key: none
Macro:
C-x b ;; switch-to-buffer
.em ;; self-insert-command * 3
<tab> ;; pabbrev-expand-maybe
RET ;; newline-and-indent
Which at least gives you some of the function names. But you'll see that RET is labeled as 'newline-and-indent which is incorrect because at the time of the macro execution, the minibuffer is active and the binding is in fact 'minibuffer-complete-and-exit. Similarly, the proper binding for TAB is 'minibuffer-complete.
I made a package that allows pretty much exactly this at https://github.com/Silex/elmacro
It has some quirks but it works pretty well... for example, the following macro:
F3 C-e M-b M-u C-a C-n F4
Generates the following elisp:
(defun upcase-last-word ()
"Change me!"
(interactive)
(move-end-of-line 1)
(backward-word 1)
(upcase-word 1)
(move-beginning-of-line 1)
(next-line 1 1))

Emacs C-h c doesn't seem to work for chords 3 combinations long?

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?
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).