summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Weiner <rsw@gnu.org>2017-12-08 15:20:41 -0500
committerOleh Krehel <ohwoeowho@gmail.com>2017-12-09 14:01:50 +0100
commita0ce6a7558e48b2ae150042a3e3cd559ba26152c (patch)
tree5faf9394cad0b58f4d203946d041c337078512f7
parentc08fc7c1c6997f7e843175e632d3d812e9f5a5b5 (diff)
Add avy-mouse-event-window and fix typo
Fixes #226
-rw-r--r--avy.el12
1 files changed, 11 insertions, 1 deletions
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