From 301d4bda667f8fe84ab5e72a5869b7e41d3e98d9 Mon Sep 17 00:00:00 2001 From: Stanislav Kljuhhin Date: Tue, 9 Apr 2024 21:20:41 +0200 Subject: [PATCH] Improve paging hint * which-key.el (which-key--next-page-hint): avoid suggesting C-h when it is known not to work; suggest alternatives that are likely to work. --- which-key.el | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/which-key.el b/which-key.el index 660ff22..6a6c887 100644 --- a/which-key.el +++ b/which-key.el @@ -2151,19 +2151,26 @@ max-lines max-width avl-lines avl-width (which-key--pages-height result)) (message "%s" text))) (defun which-key--next-page-hint (prefix-keys) - "Return string for next page hint." - (let* ((paging-key (concat prefix-keys " " which-key-paging-key)) - (paging-key-bound (eq 'which-key-C-h-dispatch - (key-binding (kbd paging-key)))) - (key (key-description (vector help-char))) - (key (if paging-key-bound - (concat key " or " which-key-paging-key) - key))) - (when (and which-key-use-C-h-commands - (not (equal (vector help-char) - (vconcat (kbd prefix-keys))))) - (which-key--propertize (format "[%s paging/help]" key) - 'face 'which-key-note-face)))) + "Return string for next page hint." + (when which-key-use-C-h-commands + (let* ((user-paging-key (concat prefix-keys " " which-key-paging-key)) + (paging-key (concat prefix-keys " " (help-key))) + (help-prefix (or (string-prefix-p (help-key) prefix-keys) + (string-prefix-p "" prefix-keys))) + (keys '())) + (when (eq 'which-key-C-h-dispatch + (key-binding (kbd user-paging-key))) + (push which-key-paging-key keys)) + (unless help-prefix + (push "?" keys) + (push "" keys) + (unless (key-binding (kbd paging-key)) + (push (help-key) keys))) + (when keys + (which-key--propertize (format "[%s%spaging/help]" + (string-join keys " or ") + which-key-separator) + 'face 'which-key-note-face))))) (eval-and-compile (if (fboundp 'universal-argument--description)