From ead6b70fd0910ead6db01ac8762918f48b6a5e5c Mon Sep 17 00:00:00 2001 From: Chris Perkins Date: Sat, 28 Nov 2015 11:15:21 -0700 Subject: [PATCH] Display prefix names in terminal-mode When running emacs in a terminal (or at least, in iTerm), keys are not passed through to emacs the same way that they are in graphical mode. For example, M-m (important in spacemacs) is the key-sequence `[134217837]` in graphical emacs, but `[27 109]` ("ESC m") in terminal. The variable `which-key-prefix-name-alst` only has a mapping for the former (the 134217837), and so the names of submenus all show up as "+prefix", limiting discoverability. This commit converts the key sequence into a canonical form (eg: converts `[27 109]` into `[134217837]`) in `which-key--maybe-replace-prefix-name`, so that the prefixes are found. I think some work is probably needed for `which-key-prefix-title-alist` too, but I'm not entirely sure what that's used for, so I didn't mess with it. --- which-key.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/which-key.el b/which-key.el index f5e5c79dd54..fc82da92e90 100644 --- a/which-key.el +++ b/which-key.el @@ -1109,9 +1109,10 @@ and DESC is the description that is possibly replaced using the `which-key-prefix-name-alist'. Whether or not a replacement occurs return the new STRING." (let* ((alist which-key-prefix-name-alist) - (res (assoc key-lst alist)) + (canonical-key-lst (listify-key-sequence (kbd (key-description key-lst)))) + (res (assoc canonical-key-lst alist)) (mode-alist (assq major-mode alist)) - (mode-res (when mode-alist (assoc key-lst mode-alist)))) + (mode-res (when mode-alist (assoc canonical-key-lst mode-alist)))) (cond (mode-res (cdr mode-res)) (res (cdr res)) (t desc))))