mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-24 00:40:35 -08:00
Add support for evil's auxiliary maps in show-keymap functions
This commit is contained in:
parent
4042f06564
commit
2c915407e1
1 changed files with 39 additions and 21 deletions
60
which-key.el
60
which-key.el
|
|
@ -646,6 +646,12 @@ update.")
|
|||
(defvar which-key--previous-frame-size nil)
|
||||
(defvar which-key--prefix-title-alist nil)
|
||||
(defvar which-key--debug nil)
|
||||
(defvar which-key--evil-keys-regexp (eval-when-compile
|
||||
(regexp-opt '("-state"))))
|
||||
(defvar which-key--ignore-non-evil-keys-regexp
|
||||
(eval-when-compile
|
||||
(regexp-opt '("mouse-" "wheel-" "remap" "drag-" "scroll-bar"
|
||||
"select-window" "switch-frame" "which-key-"))))
|
||||
(defvar which-key--ignore-keys-regexp
|
||||
(eval-when-compile
|
||||
(regexp-opt '("mouse-" "wheel-" "remap" "drag-" "scroll-bar"
|
||||
|
|
@ -1692,27 +1698,39 @@ ones. PREFIX is for internal use and should not be used."
|
|||
(lambda (ev def)
|
||||
(let* ((key (append prefix (list ev)))
|
||||
(key-desc (key-description key)))
|
||||
(unless (or (string-match-p which-key--ignore-keys-regexp key-desc)
|
||||
(eq ev 'menu-bar))
|
||||
(if (and (keymapp def)
|
||||
(or all
|
||||
;; event 27 is escape, so this will pick up meta
|
||||
;; bindings and hopefully not too much more
|
||||
(and (numberp ev) (= ev 27))))
|
||||
(setq bindings
|
||||
(append bindings
|
||||
(which-key--get-keymap-bindings def t key)))
|
||||
(when def
|
||||
(cl-pushnew
|
||||
(cons key-desc
|
||||
(cond
|
||||
((keymapp def) "Prefix Command")
|
||||
((symbolp def) (copy-sequence (symbol-name def)))
|
||||
((eq 'lambda (car-safe def)) "lambda")
|
||||
((eq 'menu-item (car-safe def)) "menu-item")
|
||||
((stringp def) def)
|
||||
(t "unknown")))
|
||||
bindings :test (lambda (a b) (string= (car a) (car b)))))))))
|
||||
(cond ((or (string-match-p
|
||||
which-key--ignore-non-evil-keys-regexp key-desc)
|
||||
(eq ev 'menu-bar)))
|
||||
;; extract evil keys corresponding to current state
|
||||
((and (keymapp def)
|
||||
(boundp 'evil-state)
|
||||
(bound-and-true-p evil-local-mode)
|
||||
(string-match-p (format "<%s-state>$" evil-state) key-desc))
|
||||
(setq bindings
|
||||
(append bindings
|
||||
(which-key--get-keymap-bindings def all prefix))))
|
||||
((and (keymapp def)
|
||||
(string-match-p which-key--evil-keys-regexp key-desc)))
|
||||
((and (keymapp def)
|
||||
(or all
|
||||
;; event 27 is escape, so this will pick up meta
|
||||
;; bindings and hopefully not too much more
|
||||
(and (numberp ev) (= ev 27))))
|
||||
(setq bindings
|
||||
(append bindings
|
||||
(which-key--get-keymap-bindings def t key))))
|
||||
(t
|
||||
(when def
|
||||
(cl-pushnew
|
||||
(cons key-desc
|
||||
(cond
|
||||
((keymapp def) "Prefix Command")
|
||||
((symbolp def) (copy-sequence (symbol-name def)))
|
||||
((eq 'lambda (car-safe def)) "lambda")
|
||||
((eq 'menu-item (car-safe def)) "menu-item")
|
||||
((stringp def) def)
|
||||
(t "unknown")))
|
||||
bindings :test (lambda (a b) (string= (car a) (car b)))))))))
|
||||
keymap)
|
||||
bindings))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue