[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/which-key 8554a9f 17/51: Generalize C-h commands to use
From: |
Stefan Monnier |
Subject: |
[elpa] externals/which-key 8554a9f 17/51: Generalize C-h commands to use help-char |
Date: |
Tue, 8 Sep 2020 10:26:17 -0400 (EDT) |
branch: externals/which-key
commit 8554a9f171d565d13ff5c18d594ae055adcd53f1
Author: Justin Burkett <justin@burkett.cc>
Commit: Justin Burkett <justin@burkett.cc>
Generalize C-h commands to use help-char
help-char defaults to C-h. This removes the assumption that help-char is
set to
C-h.
See #228
---
which-key.el | 52 ++++++++++++++++++++++++++++++----------------------
1 file changed, 30 insertions(+), 22 deletions(-)
diff --git a/which-key.el b/which-key.el
index 1a0f5c6..f3334e1 100644
--- a/which-key.el
+++ b/which-key.el
@@ -407,18 +407,20 @@ prefixes in `which-key-paging-prefixes'"
;; :type '(repeat symbol))
(defcustom which-key-use-C-h-commands t
- "Use C-h for paging if non-nil. Normally C-h after a prefix
- calls `describe-prefix-bindings'. This changes that command to
- a which-key paging command when which-key-mode is active."
+ "Use C-h (or whatever `help-char' is set to) for paging if
+non-nil. Normally C-h after a prefix calls
+`describe-prefix-bindings'. This changes that command to a
+which-key paging command when which-key-mode is active."
:group 'which-key
:type 'boolean)
(defcustom which-key-show-early-on-C-h nil
- "Show the which-key buffer before if C-h is pressed in the
-middle of a prefix before the which-key buffer would normally be
-triggered through the idle delay. If combined with the following
-settings, which-key will effectively only show when triggered
-\"manually\" using C-h.
+ "Show the which-key buffer before if C-h (or whatever
+`help-char' is set to) is pressed in the middle of a prefix
+before the which-key buffer would normally be triggered through
+the idle delay. If combined with the following settings,
+which-key will effectively only show when triggered \"manually\"
+using C-h.
\(setq `which-key-idle-delay' 10000)
\(setq `which-key-idle-secondary-delay' 0.05)
@@ -435,11 +437,11 @@ Note that `which-key-idle-delay' should be set before
turning on
(defvar which-key-C-h-map
(let ((map (make-sparse-keymap)))
- (dolist (bind '(("\C-a" . which-key-abort)
+ (dolist (bind `(("\C-a" . which-key-abort)
("a" . which-key-abort)
("\C-d" . which-key-toggle-docstrings)
("d" . which-key-toggle-docstrings)
- ("\C-h" . which-key-show-standard-help)
+ (,(vector help-char) . which-key-show-standard-help)
("h" . which-key-show-standard-help)
("\C-n" . which-key-show-next-page-cycle)
("n" . which-key-show-next-page-cycle)
@@ -2047,7 +2049,9 @@ max-lines max-width avl-lines avl-width
(which-key--pages-height result))
(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 (if paging-key-bound which-key-paging-key "C-h")))
+ (key (if paging-key-bound
+ which-key-paging-key
+ (key-description (vector help-char)))))
(when which-key-use-C-h-commands
(which-key--propertize (format "[%s paging/help]" key)
'face 'which-key-note-face))))
@@ -2094,7 +2098,7 @@ including prefix arguments."
(define-key map (kbd which-key-paging-key) #'which-key-C-h-dispatch)
(when which-key-use-C-h-commands
;; Show next page even when C-h is pressed
- (define-key map (kbd "C-h") #'which-key-C-h-dispatch))
+ (define-key map (vector help-char) #'which-key-C-h-dispatch))
map)))
(defun which-key--process-page (pages-obj)
@@ -2513,14 +2517,18 @@ is selected interactively by mode in
`minor-mode-map-alist'."
(which-key--create-pages bindings nil keymap-name))
(which-key--show-page)))
(unless no-paging
- (let* ((key (key-description (list (read-key))))
- (next-def (lookup-key keymap (kbd key))))
- (cond ((and which-key-use-C-h-commands (string= "C-h" key))
+ (let* ((key (read-key))
+ (key-desc (key-description (list key)))
+ (next-def (lookup-key keymap (vector key))))
+ (cond ((and which-key-use-C-h-commands
+ (numberp key) (= key help-char))
(which-key-C-h-dispatch))
((keymapp next-def)
(which-key--hide-popup-ignore-command)
- (which-key--show-keymap (concat keymap-name " " key) next-def
- (cons keymap-name keymap)))
+ (which-key--show-keymap
+ (concat keymap-name " " key-desc)
+ next-def
+ (cons keymap-name keymap)))
(t (which-key--hide-popup))))))))
(defun which-key--evil-operator-filter (binding)
@@ -2551,18 +2559,18 @@ is selected interactively by mode in
`minor-mode-map-alist'."
formatted-keys
nil "evil operator/motion keys"))
(which-key--show-page)))))
- (let* ((key (key-description (list (read-key)))))
- (when (member key '("f" "F" "t" "T" "`"))
+ (let* ((key (read-key)))
+ (when (member key '(?f ?F ?t ?T ?`))
;; these keys trigger commands that read the next char manually
(setq which-key--inhibit-next-operator-popup t))
- (cond ((and which-key-use-C-h-commands (string= "C-h" key))
+ (cond ((and which-key-use-C-h-commands (numberp key) (= key help-char))
(which-key-C-h-dispatch))
- ((string= key "ESC")
+ ((and (numberp key) (= key ?\C-\[))
(which-key--hide-popup)
(keyboard-quit))
(t
(which-key--hide-popup)
- (setq unread-command-events (listify-key-sequence key))))))))
+ (setq unread-command-events (vector key))))))))
(defun which-key--create-buffer-and-show
(&optional prefix-keys from-keymap filter prefix-title)
- [elpa] externals/which-key 2cb5ceb 12/51: Fix paging in which-key-manual-update, (continued)
- [elpa] externals/which-key 2cb5ceb 12/51: Fix paging in which-key-manual-update, Stefan Monnier, 2020/09/08
- [elpa] externals/which-key a256c4b 13/51: Use which-key-idle-secondary-delay value in manual updates, Stefan Monnier, 2020/09/08
- [elpa] externals/which-key a916c9a 15/51: Fix typos (#222), Stefan Monnier, 2020/09/08
- [elpa] externals/which-key 45bfcd3 22/51: Make which-key-show prefix mode-line work like top and bottom, Stefan Monnier, 2020/09/08
- [elpa] externals/which-key 1231016 29/51: More workflow fixes, Stefan Monnier, 2020/09/08
- [elpa] externals/which-key 7bc87e0 41/51: Test once a month, Stefan Monnier, 2020/09/08
- [elpa] externals/which-key ebb4e92 47/51: Add which-key-add-keymap-based-replacements, Stefan Monnier, 2020/09/08
- [elpa] externals/which-key e048b2a 48/51: Stop testing against v24.5, Stefan Monnier, 2020/09/08
- [elpa] externals/which-key d794c4a 51/51: Improve keymap-based-replacement description in README, Stefan Monnier, 2020/09/08
- [elpa] externals/which-key cf8572a 07/51: which-key-persistent-popup-p -> which-key-persistent-popup, Stefan Monnier, 2020/09/08
- [elpa] externals/which-key 8554a9f 17/51: Generalize C-h commands to use help-char,
Stefan Monnier <=
- [elpa] externals/which-key 5cec113 10/51: Announce which-key-manual-update, Stefan Monnier, 2020/09/08
- [elpa] externals/which-key dcb9820 16/51: Default to imprecise window fitting on terminal, Stefan Monnier, 2020/09/08
- [elpa] externals/which-key e554326 49/51: Remove testing badge from README, Stefan Monnier, 2020/09/08
- [elpa] externals/which-key db3d003 21/51: Add full keymap versions of show-{major, minor}-mode, Stefan Monnier, 2020/09/08
- [elpa] externals/which-key 8b49ae9 42/51: Fix last commit, Stefan Monnier, 2020/09/08
- [elpa] externals/which-key b11227b 23/51: Strip out advice in command docstrings, Stefan Monnier, 2020/09/08
- [elpa] externals/which-key 9ff54ff 37/51: Fix short windows being resized, Stefan Monnier, 2020/09/08
- [elpa] externals/which-key 9550707 40/51: Merge remote-tracking branch 'hlissner/patch-1', Stefan Monnier, 2020/09/08
- [elpa] externals/which-key 3642c11 45/51: Speed up which-key--maybe-replace, Stefan Monnier, 2020/09/08
- [elpa] externals/which-key da1abb4 27/51: Fix previous commit, Stefan Monnier, 2020/09/08