branch: master commit a0ce6a7558e48b2ae150042a3e3cd559ba26152c Author: Bob Weiner <r...@gnu.org> Commit: Oleh Krehel <ohwoeo...@gmail.com>
Add avy-mouse-event-window and fix typo Fixes #226 --- avy.el | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/avy.el b/avy.el index 877e6b4..c03bb61 100644 --- a/avy.el +++ b/avy.el @@ -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