Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

Does paging work for <escape>- key sequences? #371

Open
deen1 opened this issue Apr 12, 2024 · 2 comments
Open

Does paging work for <escape>- key sequences? #371

deen1 opened this issue Apr 12, 2024 · 2 comments

Comments

@deen1
Copy link

deen1 commented Apr 12, 2024

Apologies if this has been raised before, but I couldn't quite find an issue that addressed this head on. I found this Stack Exchange post, which had a couple of answers (but the question is focused on Spacemacs, which I don't use), and this possibly related issue, #223.

When hitting <escape> in a number of contexts, which-key pops up in a side-window with a number of options – see first screenshot below (which was made via emacs -Q, so hopefully should be reproducible). But it is not possible to page them, as <escape> C-h is bound to something else (I think it's (mark-defun)) and the side-window is killed.

2024-04-12-153833_295x929_scrot

Following the paging section in the README, I tried running emacs -Q, loading which-key and using the following config:

(which-key-side-window-right)
(which-key-mode)
(setq which-key-use-C-h-commands t)

(define-key which-key-mode-map (kbd "<escape> <f5>") 'which-key-C-h-dispatch)

Unfortunately, hitting <escape> no longer offers all the previous command descriptions, just the <f5> for paging (see second screenshot).

Is this simply an unavoidable issue with <escape>, or is there some way around it?

2024-04-12-154011_320x78_scrot

@justbur
Copy link
Owner

justbur commented Apr 13, 2024

I believe emacs will intercept the sequence <escape> C-h before which-key can handle it. The problem is that emacs translates that sequence to C-M-h. I can't find the reference for it right now, but essentially <escape> x, where x could be any key, translates immediately to M-x, so you're unintentionally invoking C-M-h instead of something + C-h, if that makes sense.

This behavior is something particular to <escape> and would be difficult if not impossible to circumvent unfortunately.

@deen1
Copy link
Author

deen1 commented Apr 14, 2024

I believe emacs will intercept the sequence C-h before which-key can
handle it. The problem is that emacs translates that sequence to C-M-h.

This is what I understood, but I had hoped that by adding e.g. <f5> as the paging key (as far as I can tell, <escape>-<f5> is not bound to anything) we could circumvent C-M-h binding.

But I guess you're saying that Emacs basically tries to reserve any key combination beginning with <escape>, which may be why (define-key which-key-mode-map (kbd "<escape> <f5>") 'which-key-C-h-dispatch) doesn't work as intended.

That's a shame, but I can live with it. Thanks for your input on this!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants