branch: master commit 576563da24ef783fa8a6de71eb1f95aacf4862c3 Author: Oleh Krehel <ohwoeo...@gmail.com> Commit: Oleh Krehel <ohwoeo...@gmail.com>
ivy.el (with-ivy-window): Ensure window is live * ivy.el (ivy--get-window): New defun. --- ivy.el | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-) diff --git a/ivy.el b/ivy.el index b6c8b08..10c019d 100644 --- a/ivy.el +++ b/ivy.el @@ -281,7 +281,7 @@ When non-nil, it should contain one %d.") "Execute BODY in the window from which `ivy-read' was called." (declare (indent 0) (debug t)) - `(with-selected-window (ivy-state-window ivy-last) + `(with-selected-window (ivy--get-window ivy-last) ,@body)) (defun ivy--done (text) @@ -617,6 +617,15 @@ If the input is empty, select the previous history element instead." action (cadr (nth (car action) action)))))) +(defun ivy--get-window (state) + "Get the window from STATE." + (let ((window (ivy-state-window state))) + (if (window-live-p window) + window + (if (= (length (window-list)) 1) + (selected-window) + (next-window ))))) + (defun ivy--actionp (x) "Return non-nil when X is a list of actions." (and x (listp x) (not (eq (car x) 'closure))))