[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 1dd91df 01/39: Implement #182
From: |
Justin Burkett |
Subject: |
[elpa] master 1dd91df 01/39: Implement #182 |
Date: |
Thu, 21 Jun 2018 15:48:10 -0400 (EDT) |
branch: master
commit 1dd91df43606de66580060a8b9b6edc9145c34ba
Author: Justin Burkett <address@hidden>
Commit: Justin Burkett <address@hidden>
Implement #182
Allow single digit arg to be set after C-h
---
which-key.el | 50 ++++++++++++++++++++++++++++++++++++--------------
1 file changed, 36 insertions(+), 14 deletions(-)
diff --git a/which-key.el b/which-key.el
index f973c19..41dfb33 100644
--- a/which-key.el
+++ b/which-key.el
@@ -412,7 +412,16 @@ prefixes in `which-key-paging-prefixes'"
("\C-p" . which-key-show-previous-page-cycle)
("p" . which-key-show-previous-page-cycle)
("\C-u" . which-key-undo-key)
- ("u" . which-key-undo-key)))
+ ("u" . which-key-undo-key)
+ ("1" . which-key-digit-argument)
+ ("2" . which-key-digit-argument)
+ ("3" . which-key-digit-argument)
+ ("4" . which-key-digit-argument)
+ ("5" . which-key-digit-argument)
+ ("6" . which-key-digit-argument)
+ ("7" . which-key-digit-argument)
+ ("8" . which-key-digit-argument)
+ ("9" . which-key-digit-argument)))
(define-key map (car bind) (cdr bind)))
map)
"Keymap for C-h commands.")
@@ -2016,12 +2025,14 @@ enough space based on your settings and frame size."
prefix-keys)
;;; Paging functions
;;;###autoload
-(defun which-key-reload-key-sequence (key-seq)
+(defun which-key-reload-key-sequence (&optional key-seq)
"Simulate entering the key sequence KEY-SEQ.
KEY-SEQ should be a list of events as produced by
-`listify-key-sequence'. Any prefix arguments that were used are
-reapplied to the new key sequence."
- (let ((next-event (mapcar (lambda (ev) (cons t ev)) key-seq)))
+`listify-key-sequence'. If nil, KEY-SEQ defaults to
+`which-key--current-key-list'. Any prefix arguments that were
+used are reapplied to the new key sequence."
+ (let* ((key-seq (or key-seq (which-key--current-key-list)))
+ (next-event (mapcar (lambda (ev) (cons t ev)) key-seq)))
(setq prefix-arg current-prefix-arg
unread-command-events next-event)))
@@ -2029,7 +2040,7 @@ reapplied to the new key sequence."
"Show the next page of keys."
(let ((next-page (if which-key--current-page-n
(+ which-key--current-page-n delta) 0)))
- (which-key-reload-key-sequence (which-key--current-key-list))
+ (which-key-reload-key-sequence)
(if which-key--last-try-2-loc
(let ((which-key-side-window-location which-key--last-try-2-loc)
(which-key--multiple-locations t))
@@ -2038,7 +2049,7 @@ reapplied to the new key sequence."
(which-key--start-paging-timer)))
;;;###autoload
-(defun which-key-show-standard-help ()
+(defun which-key-show-standard-help (&optional _)
"Call the command in `which-key--prefix-help-cmd-backup'.
Usually this is `describe-prefix-bindings'."
(interactive)
@@ -2075,7 +2086,7 @@ case do nothing."
(which-key-turn-page -1))))
;;;###autoload
-(defun which-key-show-next-page-cycle ()
+(defun which-key-show-next-page-cycle (&optional _)
"Show the next page of keys, cycling from end to beginning
after last page."
(interactive)
@@ -2083,7 +2094,7 @@ after last page."
(which-key-turn-page 1)))
;;;###autoload
-(defun which-key-show-previous-page-cycle ()
+(defun which-key-show-previous-page-cycle (&optional _)
"Show the previous page of keys, cycling from beginning to end
after first page."
(interactive)
@@ -2091,7 +2102,7 @@ after first page."
(which-key-turn-page -1)))
;;;###autoload
-(defun which-key-show-top-level ()
+(defun which-key-show-top-level (&optional _)
"Show top-level bindings."
(interactive)
(setq which-key--using-top-level "Top-level bindings")
@@ -2113,7 +2124,7 @@ current evil state. "
(message "which-key: No map named %s" map-sym))))
;;;###autoload
-(defun which-key-undo-key ()
+(defun which-key-undo-key (&optional _)
"Undo last keypress and force which-key update."
(interactive)
(let* ((key-lst (butlast (which-key--current-key-list)))
@@ -2129,13 +2140,22 @@ current evil state. "
(t (which-key-show-top-level)))))
(defalias 'which-key-undo 'which-key-undo-key)
-(defun which-key-abort ()
+(defun which-key-abort (&optional _)
"Abort key sequence."
(interactive)
(let ((which-key-inhibit t))
(which-key--hide-popup-ignore-command)
(keyboard-quit)))
+(defun which-key-digit-argument (key)
+ "Version of `digit-argument' for use in `which-key-C-h-map'."
+ (interactive)
+ (let ((last-command-event (string-to-char key)))
+ (digit-argument key))
+ (message "lce %s key %s pf %s" last-command-event key prefix-arg)
+ (let ((current-prefix-arg prefix-arg))
+ (which-key-reload-key-sequence)))
+
;;;###autoload
(defun which-key-C-h-dispatch ()
"Dispatch C-h commands by looking up key in
@@ -2166,12 +2186,14 @@ prefix) if `which-key-use-C-h-commands' is non nil."
" \\[which-key-show-standard-help]"
which-key-separator "help,"
" \\[which-key-abort]"
- which-key-separator "abort"))
+ which-key-separator "abort"
+ " 1..9"
+ which-key-separator "digit-arg"))
'face 'which-key-note-face)))
(key (string (read-key prompt)))
(cmd (lookup-key which-key-C-h-map key))
(which-key-inhibit t))
- (if cmd (funcall cmd) (which-key-turn-page 0)))))
+ (if cmd (funcall cmd key) (which-key-turn-page 0)))))
;;; Update
- [elpa] master updated (81c4a3d -> fb09d75), Justin Burkett, 2018/06/21
- [elpa] master 1dd91df 01/39: Implement #182,
Justin Burkett <=
- [elpa] master 1219622 02/39: Remove debugging message, Justin Burkett, 2018/06/21
- [elpa] master c71fbbb 03/39: Add option to show docstrings in which-key buffer, Justin Burkett, 2018/06/21
- [elpa] master fce520f 08/39: Improve which-key--format-and-replace, Justin Burkett, 2018/06/21
- [elpa] master caa18b2 12/39: Fix descriptions of keys involving meta when showing keymaps, Justin Burkett, 2018/06/21
- [elpa] master e5db4b6 07/39: Handle null description in which-key--propertize-description, Justin Burkett, 2018/06/21
- [elpa] master 0aae4c8 04/39: Improve which-key-show-docstrings option, Justin Burkett, 2018/06/21
- [elpa] master 6a4d2c2 09/39: Extract which-key--ignore-keys-regexp and which-key-show-keymap-1, Justin Burkett, 2018/06/21
- [elpa] master ca991b0 11/39: Autoload the show keymap functions, Justin Burkett, 2018/06/21
- [elpa] master fd714bc 13/39: Fix docstring of which-key--get-keymap-bindings, Justin Burkett, 2018/06/21
- [elpa] master b5f7063 15/39: Detect menu-items in which-key--get-keymap-bindings, Justin Burkett, 2018/06/21