[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/which-key fc88551 05/32: Remove pseudo binding stuff
From: |
ELPA Syncer |
Subject: |
[elpa] externals/which-key fc88551 05/32: Remove pseudo binding stuff |
Date: |
Wed, 30 Jun 2021 18:57:27 -0400 (EDT) |
branch: externals/which-key
commit fc8855187f087635de4162071882405861460e05
Author: Justin Burkett <justin@burkett.cc>
Commit: Justin Burkett <justin@burkett.cc>
Remove pseudo binding stuff
It's not necessary anymore with manual parsing of the keymaps
---
which-key.el | 89 ++++++++++++------------------------------------------------
1 file changed, 17 insertions(+), 72 deletions(-)
diff --git a/which-key.el b/which-key.el
index e6ac0c4..5c2ca80 100644
--- a/which-key.el
+++ b/which-key.el
@@ -525,24 +525,6 @@ it."
:group 'which-key
:type 'boolean)
-(defcustom which-key-enable-extended-define-key nil
- "Advise `define-key' to make which-key aware of definitions of the form
-
- \(define-key KEYMAP KEY '(\"DESCRIPTION\" . DEF))
-
-With the advice, this definition will have the side effect of
-creating a replacement in `which-key-replacement-alist' that
-replaces DEF with DESCRIPTION when the key sequence ends in
-KEY. Using a cons cell like this is a valid definition for
-`define-key'. All this does is to make which-key aware of it.
-
-Since many higher level keybinding functions use `define-key'
-internally, this will affect most if not all of those as well.
-
-This variable must be set before loading which-key."
- :group 'which-key
- :type 'boolean)
-
;; Hooks
(defcustom which-key-init-buffer-hook '()
"Hook run when which-key buffer is initialized."
@@ -938,8 +920,7 @@ actually bound to write-file before performing the
replacement."
replacement
(car-safe replacement)))
(command (cdr-safe replacement)))
- (define-key keymap (which-key--pseudo-key (kbd key))
- `(which-key ,(cons string command))))
+ (define-key keymap (kbd key) (cons string command)))
(setq key (pop more)
replacement (pop more))))
(put 'which-key-add-keymap-based-replacements 'lisp-indent-function 'defun)
@@ -1044,19 +1025,6 @@ If AT-ROOT is non-nil the binding is also placed at the
root of MAP."
(which-key-define-key-recursively df key def t)))
map))
-(defun which-key--process-define-key-args (keymap key def)
- "When DEF takes the form (\"DESCRIPTION\". DEF), make sure
-which-key uses \"DESCRIPTION\" for this binding. This function is
-meant to be used as :before advice for `define-key'."
- (with-demoted-errors "Which-key extended define-key error: %s"
- (when (and (consp def)
- (stringp (car def))
- (symbolp (cdr def)))
- (define-key keymap (which-key--pseudo-key key) `(which-key ,def)))))
-
-(when which-key-enable-extended-define-key
- (advice-add #'define-key :before #'which-key--process-define-key-args))
-
;;; Functions for computing window sizes
(defun which-key--text-width-to-total (text-width)
@@ -1493,20 +1461,6 @@ local bindings coming first. Within these categories
order using
(string-match-p binding-regexp
(cdr key-binding)))))))
-(defun which-key--get-pseudo-binding (key-binding &optional prefix)
- (let* ((key (kbd (car key-binding)))
- (pseudo-binding (key-binding (which-key--pseudo-key key prefix))))
- (when pseudo-binding
- (let* ((command-replacement (cadr pseudo-binding))
- (pseudo-desc (car command-replacement))
- (pseudo-def (cdr command-replacement)))
- (when (and (stringp pseudo-desc)
- (or (null pseudo-def)
- ;; don't verify keymaps
- (keymapp pseudo-def)
- (eq pseudo-def (key-binding key))))
- (cons (car key-binding) pseudo-desc))))))
-
(defsubst which-key--replace-in-binding (key-binding repl)
(cond ((or (not (consp repl)) (null (cdr repl)))
key-binding)
@@ -1542,26 +1496,23 @@ local bindings coming first. Within these categories
order using
"Use `which-key--replacement-alist' to maybe replace KEY-BINDING.
KEY-BINDING is a cons cell of the form \(KEY . BINDING\) each of
which are strings. KEY is of the form produced by `key-binding'."
- (let* ((pseudo-binding (which-key--get-pseudo-binding key-binding prefix)))
- (if pseudo-binding
- pseudo-binding
- (let* ((replacer (if which-key-allow-multiple-replacements
- #'which-key--replace-in-repl-list-many
- #'which-key--replace-in-repl-list-once)))
- (pcase
- (apply replacer
- (list key-binding
- (cdr-safe (assq major-mode
which-key-replacement-alist))))
- (`(replaced . ,repl)
- (if which-key-allow-multiple-replacements
- (pcase (apply replacer (list repl which-key-replacement-alist))
- (`(replaced . ,repl) repl)
- ('() repl))
- repl))
- ('()
- (pcase (apply replacer (list key-binding
which-key-replacement-alist))
+ (let* ((replacer (if which-key-allow-multiple-replacements
+ #'which-key--replace-in-repl-list-many
+ #'which-key--replace-in-repl-list-once)))
+ (pcase
+ (apply replacer
+ (list key-binding
+ (cdr-safe (assq major-mode which-key-replacement-alist))))
+ (`(replaced . ,repl)
+ (if which-key-allow-multiple-replacements
+ (pcase (apply replacer (list repl which-key-replacement-alist))
(`(replaced . ,repl) repl)
- ('() key-binding))))))))
+ ('() repl))
+ repl))
+ ('()
+ (pcase (apply replacer (list key-binding which-key-replacement-alist))
+ (`(replaced . ,repl) repl)
+ ('() key-binding))))))
(defsubst which-key--current-key-list (&optional key-str)
(append (listify-key-sequence (which-key--current-prefix))
@@ -1593,12 +1544,6 @@ which are strings. KEY is of the form produced by
`key-binding'."
(or (eq lookup (intern (cdr keydesc)))
(and (keymapp lookup) (string= (cdr keydesc) "Prefix Command"))))))
-(defun which-key--pseudo-key (key &optional prefix)
- "Replace the last key in the sequence KEY by a special symbol
-in order for which-key to allow looking up a description for the key."
- (let ((seq (listify-key-sequence key)))
- (vconcat (or prefix (butlast seq)) [which-key] (last seq))))
-
(defun which-key--maybe-get-prefix-title (keys)
"KEYS is a string produced by `key-description'.
A title is possibly returned using
- [elpa] externals/which-key 28f386c 25/32: Fix key sort order functions, (continued)
- [elpa] externals/which-key 28f386c 25/32: Fix key sort order functions, ELPA Syncer, 2021/06/30
- [elpa] externals/which-key 11471fb 21/32: Add install python step to github action, ELPA Syncer, 2021/06/30
- [elpa] externals/which-key e236920 14/32: Merge branch 'alt-get-bindings', ELPA Syncer, 2021/06/30
- [elpa] externals/which-key 7cfbf8c 23/32: Turn off fail-fast in github action, ELPA Syncer, 2021/06/30
- [elpa] externals/which-key eb5a2e3 28/32: Clean up some docstrings, ELPA Syncer, 2021/06/30
- [elpa] externals/which-key cd0c48c 29/32: Clarify usage of keymap replacements in docstrings and README, ELPA Syncer, 2021/06/30
- [elpa] externals/which-key 27d9fec 32/32: Fix compiler warnings, ELPA Syncer, 2021/06/30
- [elpa] externals/which-key 4c27fc0 30/32: Improve which-key-add-keymap-based-replacements., ELPA Syncer, 2021/06/30
- [elpa] externals/which-key 8a558e6 06/32: Update tests, ELPA Syncer, 2021/06/30
- [elpa] externals/which-key e42d946 11/32: Fix prefix sorting, ELPA Syncer, 2021/06/30
- [elpa] externals/which-key fc88551 05/32: Remove pseudo binding stuff,
ELPA Syncer <=
- [elpa] externals/which-key 465d2fb 10/32: Fix add-keymap-based-bindings and associated test, ELPA Syncer, 2021/06/30
- [elpa] externals/which-key 6ae80f5 22/32: Try without cask, ELPA Syncer, 2021/06/30
- [elpa] externals/which-key d621634 19/32: Try with cask again, ELPA Syncer, 2021/06/30
- [elpa] externals/which-key a55b908 04/32: Alternative approach to retrieving bindings (WIP), ELPA Syncer, 2021/06/30
- [elpa] externals/which-key 1f9c37d 03/32: Merge pull request #305 from tarsiiformes/first-line, ELPA Syncer, 2021/06/30
- [elpa] externals/which-key 4e592ed 08/32: Fix type usage and arglists for new functions, ELPA Syncer, 2021/06/30
- [elpa] externals/which-key d6b56f3 13/32: Fix detection of named prefix bindings, ELPA Syncer, 2021/06/30
- [elpa] externals/which-key 2444833 12/32: Fix menu-item bidning retrieval, ELPA Syncer, 2021/06/30
- [elpa] externals/which-key 7d344ce 17/32: Fix test, ELPA Syncer, 2021/06/30
- [elpa] externals/which-key 300c098 16/32: Update README, ELPA Syncer, 2021/06/30