Show Keys In Emacs Keymap Value

Viewed 8022

When I query the current value of the keymap, eg with M-: (current-local-map), it shows me something along these lines:

Value: 
(keymap
 (S-mouse-2 . muse-follow-name-at-mouse-other-window)
 (mouse-2 . muse-follow-name-at-mouse)
 (33554445 . muse-follow-name-at-point-other-window)
 (S-return . muse-follow-name-at-point-other-window)
 (13 . muse-follow-name-at-point)
 (return . muse-follow-name-at-point)
 keymap
 (67108924 . muse-decrease-list-item-indentation)
 (67108926 . muse-increase-list-item-indentation)
 (M-return . muse-insert-list-item)
 (33554441 . muse-previous-reference)
 (S-iso-lefttab . muse-previous-reference)
 (S-tab . muse-previous-reference)
 (S-mouse-2 . muse-follow-name-at-mouse-other-window)
 (mouse-2 . muse-follow-name-at-mouse)
 (33554445 . muse-follow-name-at-point-other-window)
 (9 . muse-next-reference)
 (tab . muse-next-reference)
 (3 keymap
    (19 . muse-search)
    (2 . muse-find-backlinks)
    (tab . muse-insert-thing)
    (9 . muse-insert-thing)
    (16 . muse-project-publish)
    (6 . muse-project-find-file)
    (61 . muse-what-changed)
    (22 . muse-browse-result)
    (27 keymap
        (20 . muse-publish-this-file))
    (33554452 . muse-publish-this-file)
    (20 . muse-project-publish-this-file)
    (12 . font-lock-mode)
    (5 . muse-edit-link-at-point)
    (1 . muse-index))
 keymap
 (27 keymap
     (9 . ispell-complete-word)))

I want instead of numbers see something more meaningful like (control ?c) return for example. How do I do that ?

6 Answers

For a more modern approach, use the which-key-show-full-keymap command from the which-key package. It will ask you for a keymap and then show you all the bindings from that keymap, exactly like it would if you press a prefix key (if which-key-mode is enabled). That is, in the minibuffer, nice and clean.

From the documentation:

which-key-show-full-keymap is an interactive autoloaded compiled Lisp function in ‘which-key.el’.

(which-key-show-full-keymap KEYMAP)

Show all bindings in KEYMAP using which-key. KEYMAP is selected interactively from all available keymaps.

You can also use helpful-variable function from helpful package available in Melpa. Here is sample output:

projectile-command-map is a variable defined in projectile.el.

Value
!        projectile-run-shell-command-in-root
&        projectile-run-async-shell-command-in-root
4 C-o    projectile-display-buffer
4 D      projectile-dired-other-window
4 a      projectile-find-other-file-other-window
....

vs. standard output:

projectile-command-map is a variable defined in ‘projectile.el’.
Its value is shown below.

Keymap for Projectile commands after ‘projectile-keymap-prefix’.
  This variable may be risky if used as a file-local variable.

Value:
(keymap
 (33 . projectile-run-shell-command-in-root)
 (38 . projectile-run-async-shell-command-in-root)
 (53 keymap
     (68 . projectile-dired-other-window)
     (15 . projectile-display-buffer)
...
Related