aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDuncan Burke2021-07-14 01:24:05 +1000
committerDuncan Burke2021-07-14 01:24:05 +1000
commit31532874651bf3268c87601eb7478e1756e220af (patch)
tree3fda5a414d2366f6375228d9e2c0082051a2d893
parent55fcce0c6143044535bc6825a68f42ca83f58f00 (diff)
downloademacs-31532874651bf3268c87601eb7478e1756e220af.tar.gz
emacs-31532874651bf3268c87601eb7478e1756e220af.zip
Add support for help-char being a generalized input event
Not all keyboard events can be represented as a character. For example, while ?\C-h is a character, represented as 8 in decimal, C-M-h is represented by 134217736 in decimal, as can be obtained from: (elt (kbd "C-M-h") 0) It is useful to allow help-char to be set to something other than a character, as characters cover only a very small region of possible input events. This is especially important because help-char is used to bring up the pagination menu (when which-key-use-C-h-commands is t), and this won't work if it conflicts with any keybinding within the prefix command that led to the activation of which-key. If help-char is left set to ?\C-h things work fine because as a convention keymaps avoid binding that due to it being the default binding for help. That is just a convention, however, and things become more difficult with a heavily user-customized set of keybindings that preclude the use of ?\C-h for that purpose. In that case, if ?\C-h cannot be used, it is much easier to find a binding for help-char that is unlikely to conflict with any bindings if it is permitted to use the full range of modifier keys. This patch modifies which-key--next-page-hint, which is the only place that broke when I set help-char to a keyboard event that wasn't a character. Rather than doing a string comparison, help-char and prefix keys are put in vectors and equality is checked that way.
-rw-r--r--which-key.el5
1 files changed, 2 insertions, 3 deletions
diff --git a/which-key.el b/which-key.el
index 0fdcb7aefb2..62f0f6153c5 100644
--- a/which-key.el
+++ b/which-key.el
@@ -1992,9 +1992,8 @@ max-lines max-width avl-lines avl-width (which-key--pages-height result))
1992 (concat key " or " which-key-paging-key) 1992 (concat key " or " which-key-paging-key)
1993 key))) 1993 key)))
1994 (when (and which-key-use-C-h-commands 1994 (when (and which-key-use-C-h-commands
1995 (or (not (stringp (kbd prefix-keys))) 1995 (not (equal (vector help-char)
1996 (not (string-equal (char-to-string help-char) 1996 (vconcat (kbd prefix-keys)))))
1997 (kbd prefix-keys)))))
1998 (which-key--propertize (format "[%s paging/help]" key) 1997 (which-key--propertize (format "[%s paging/help]" key)
1999 'face 'which-key-note-face)))) 1998 'face 'which-key-note-face))))
2000 1999