avy.el (avy-show-dispatch-help): Add and bind to "?"

Fixes abo-abo/ace-window#91
This commit is contained in:
Oleh Krehel 2019-03-25 11:46:09 +01:00
parent 152b07fe5a
commit 9a15d1f37b

16
avy.el
View File

@ -456,12 +456,28 @@ KEYS is the path from the root of `avy-tree' to LEAF."
((memq char '(27 ?\C-g)) ((memq char '(27 ?\C-g))
;; exit silently ;; exit silently
(throw 'done 'exit)) (throw 'done 'exit))
((eq char ??)
(avy-show-dispatch-help)
(throw 'done 'restart))
((mouse-event-p char) ((mouse-event-p char)
(signal 'user-error (list "Mouse event not handled" char))) (signal 'user-error (list "Mouse event not handled" char)))
(t (t
(message "No such candidate: %s, hit `C-g' to quit." (message "No such candidate: %s, hit `C-g' to quit."
(if (characterp char) (string char) char)))))) (if (characterp char) (string char) char))))))
(defun avy-show-dispatch-help ()
"Display action shortucts in echo area."
(let ((len (length "avy-action-")))
(message "%s" (mapconcat
(lambda (x)
(format "%s: %s"
(propertize
(char-to-string (car x))
'face 'aw-key-face)
(substring (symbol-name (cdr x)) len)))
avy-dispatch-alist
" "))))
(defvar avy-handler-function 'avy-handler-default (defvar avy-handler-function 'avy-handler-default
"A function to call for a bad `read-key' in `avy-read'.") "A function to call for a bad `read-key' in `avy-read'.")