Add avy-mouse-event-window and fix typo

Fixes #226
This commit is contained in:
Bob Weiner 2017-12-08 15:20:41 -05:00 committed by Oleh Krehel
parent c08fc7c1c6
commit a0ce6a7558

12
avy.el
View File

@ -434,6 +434,16 @@ KEYS is the path from the root of `avy-tree' to LEAF."
(defvar avy-current-path ""
"Store the current incomplete path during `avy-read'.")
(defun avy-mouse-event-window (char)
"If CHAR is a mouse event, return the window of the event if any or the selected window.
Return nil if not a mouse event."
(when (mouse-event-p char)
(cond ((windowp (posn-window (event-start char)))
(posn-window (event-start char)))
((framep (posn-window (event-start char)))
(frame-selected-window (posn-window (event-start char))))
(t (selected-window)))))
(defun avy-read (tree display-fn cleanup-fn)
"Select a leaf from TREE using consecutive `read-char'.
@ -442,7 +452,7 @@ associated with CHAR will be selected if CHAR is pressed. This is
commonly done by adding a CHAR overlay at LEAF position.
CLEANUP-FN should take no arguments and remove the effects of
multiple DISPLAY-FN invokations."
multiple DISPLAY-FN invocations."
(catch 'done
(setq avy-current-path "")
(while tree