branch: master
commit c68a6d898c98b27fe83c59e2f139d5c188e73ef1
Author: Oleh Krehel <[email protected]>
Commit: Oleh Krehel <[email protected]>

    ivy.el (ivy-occur-press): Don't fail if buffer was killed
---
 ivy.el | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/ivy.el b/ivy.el
index 51a4446..eb95429 100644
--- a/ivy.el
+++ b/ivy.el
@@ -3964,6 +3964,12 @@ EVENT gives the mouse position."
            (selected-window))
      (selected-window))))
 
+(defun ivy--occur-press-buffer ()
+  (let ((buffer (ivy-state-buffer ivy-last)))
+    (if (buffer-live-p buffer)
+        buffer
+      (current-buffer))))
+
 (defun ivy-occur-press ()
   "Execute action for the current candidate."
   (interactive)
@@ -3981,7 +3987,7 @@ EVENT gives the mouse position."
            (ivy-exit 'done))
       (with-ivy-window
         (setq counsel-grep-last-line nil)
-        (with-current-buffer (ivy-state-buffer ivy-last)
+        (with-current-buffer (ivy--occur-press-buffer)
           (funcall action
                    (if (and (consp coll)
                             (consp (car coll)))

Reply via email to