Allow for all operations to work across frames

* avy.el (avy-all-windows): Change the custom type to choice: this
  window/this frame/all frames.
(avy-window-list): New defun.
(avy-dowindows): Use `avy-window-list'.
(avy--process): Use `avy-window-list'.
This commit is contained in:
Oleh Krehel 2015-05-18 08:57:12 +02:00
parent dc06220ba0
commit d6b741b444

26
avy.el
View File

@ -111,8 +111,12 @@ If the commands isn't on the list, `avy-style' is used."
:type 'boolean) :type 'boolean)
(defcustom avy-all-windows t (defcustom avy-all-windows t
"When non-nil, loop though all windows for candidates." "Determine the list of windows to consider in search of candidates."
:type 'boolean) :type
'(choice
(const :tag "All Frames" all-frames)
(const :tag "This Frame" t)
(const :tag "This Window" nil)))
(defcustom avy-case-fold-search t (defcustom avy-case-fold-search t
"Non-nil if searches should ignore case." "Non-nil if searches should ignore case."
@ -244,6 +248,16 @@ multiple DISPLAY-FN invokations."
(funcall avy-handler-function char)))))) (funcall avy-handler-function char))))))
;;** Rest ;;** Rest
(defun avy-window-list ()
"Return a list of windows depending on `avy-all-windows'."
(cl-case avy-all-windows
(all-frames
(cl-mapcan #'window-list (frame-list)))
(this-frame
(window-list))
(t
(list (selected-window)))))
(defmacro avy-dowindows (flip &rest body) (defmacro avy-dowindows (flip &rest body)
"Depending on FLIP and `avy-all-windows' run BODY in each or selected window." "Depending on FLIP and `avy-all-windows' run BODY in each or selected window."
(declare (indent 1) (declare (indent 1)
@ -251,9 +265,7 @@ multiple DISPLAY-FN invokations."
`(let ((avy-all-windows (if ,flip `(let ((avy-all-windows (if ,flip
(not avy-all-windows) (not avy-all-windows)
avy-all-windows))) avy-all-windows)))
(dolist (wnd (if avy-all-windows (dolist (wnd (avy-window-list))
(window-list)
(list (selected-window))))
(with-selected-window wnd (with-selected-window wnd
(unless (memq major-mode '(image-mode doc-view-mode)) (unless (memq major-mode '(image-mode doc-view-mode))
,@body))))) ,@body)))))
@ -297,9 +309,7 @@ Use OVERLAY-FN to visualize the decision overlay."
(car candidates)) (car candidates))
(t (t
(avy--make-backgrounds (avy--make-backgrounds
(if avy-all-windows (avy-window-list))
(window-list)
(list (selected-window))))
(avy-read (avy-tree candidates avy-keys) (avy-read (avy-tree candidates avy-keys)
overlay-fn overlay-fn
#'avy--remove-leading-chars))) #'avy--remove-leading-chars)))