3

I want to unbind the keybinding C-k, which runs the command org-up-element in org mode. To do it, I first need to find out which keymap this keybinding is bound to. So I run describe-key and press C-k, here is the result:

C-k runs the command org-up-element, which is an interactive compiled Lisp
function in ‘org.el’.

It is bound to <motion-state> g h, C-c C-^.

(org-up-element)

Move to upper element.

It doesn't tell me which keymap C-k is bound to, but usually it should tell me. So my question is, why doesn't it tell me, and how can I know the keymap that C-k is bound to?

6
  • Grep the Org files org*.el for org-up-element, to see where it is bound (using define-key, for example). That will tell you what keymap it's bound in. – Drew Apr 16 at 16:06
  • @Drew orgmode doesn't bind this to C-k, so the solution won't be found in those files I think – Tyler Apr 16 at 16:36
  • Note that you don't need to unbind a key to rebind it. You just need to bind it to a keymap with a higher priority than the one it is in. That's a bit tricky when you don't know the keymap, but binding it to the local map in your orgmode hook might work. – Tyler Apr 16 at 16:38
  • You can bind a key in the keymap that is the value of (current-local-map), if that's what you're trying to do. You have also these similar functions: current-active-maps, current-global-map, current-minor-mode-maps. (And binding to nil unbinds a key.) – Drew Apr 16 at 17:34
  • @Tyler's answer is probably the best approach. You can also do this: (mapcar 'describe-keymap (current-active-maps)). Then use the [back] link in *Help* repeatedly to see each active keymap's key listing, in turn. Unless you have a recent Emacs you might need to load library help-fns+.el, to get command describe-keymap. – Drew Apr 16 at 17:40
2

C-h b lists all the keybindings currently in effect, and groups them by mode.

Similarly, C-h m displays a short description of the current major mode, and all active minor modes. This includes the keys bound to the maps for each mode. It doesn't include keys bound in the global keymap, so if you don't find your key here, that might be why.

The output from both of these commands is quite long, but you should be able to to search for the text "C-k" then back up to the previous heading to see what mode it is set in.

Re: your actual situation: C-k is bound to kill-line by default in the global map. Unless you're using some kind of starter-kit configuration, you have almost certainly rebound this in your config somewhere if it is calling org-up-element.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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