I'm trying to remap some keys in help-map, but the following does not work:

(define-key help-map [remap describe-mode] #'my-describe-mode)

Remapping in the global map does work, however:

(global-set-key [remap describe-mode] #'my-describe-mode)

Why is this? I can see that the value of help-map contains describe-mode when I call describe-variable:

help-map is a variable defined in `help.el'.
Its value is shown below.

  This variable may be risky if used as a file-local variable.

Keymap for characters following the Help key.

Value: (keymap
 (remap keymap
    (describe-mode . my-describe-mode))
 (109 . describe-mode)

Does it have something to do with C-h being a prefix key?

  • 2
    help-map is a prefix keymap (gnu.org/software/emacs/manual/html_node/emacs/…) and remapping doesn't work for this kind of keymap (gnu.org/software/emacs/manual/html_node/elisp/…). – xuchunyang Feb 8 '16 at 3:20
  • Can you please give us an example of what keyboard combination you would like to press to trigger a particular function so we can suggest some solutions? – lawlist Feb 8 '16 at 3:30
  • @xuchunyang I see. Is remapping through the global key the preferred method, then? Or is there a more idiomatic way? – Tianxiang Xiong Feb 8 '16 at 3:31
  • @TianxiangXiong According to C-h k C-h m, C-h m is in global-map (not help-map), so I think it is. – xuchunyang Feb 8 '16 at 4:48
  • 1
    @xuchunyang: Please consider posting your helpful comment as an answer, which the OP can consider accepting. Thx. – Drew Feb 8 '16 at 5:16

Your Answer

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

Browse other questions tagged or ask your own question.