emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 5f04a70 322/348: ivy.el: Move ivy-recursive-last logic to


From: Oleh Krehel
Subject: [elpa] master 5f04a70 322/348: ivy.el: Move ivy-recursive-last logic to ivy-call
Date: Sat, 8 Apr 2017 11:04:23 -0400 (EDT)

branch: master
commit 5f04a70e0f8686c46b5f5441761df65a79d9a720
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    ivy.el: Move ivy-recursive-last logic to ivy-call
    
    The reason is that `ivy-call' needs stuff from the current `ivy-last'
    for setup, i.e. deciding which action to call. But the action itself
    should be called in the context of `ivy-recursive-last'.
    
    This fixes the issue of e.g. calling `swiper', then recursively calling
    `counsel-M-x' to select `ivy-done' or `ivy-alt-done'.
    
    Fixes #924
---
 ivy.el | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/ivy.el b/ivy.el
index 5824f43..ea5ce92 100644
--- a/ivy.el
+++ b/ivy.el
@@ -355,6 +355,13 @@ action functions.")
 This should eventually become a stack so that you could use
 `ivy-read' recursively.")
 
+(defvar ivy-recursive-last nil)
+
+(defvar ivy-recursive-restore t
+  "When non-nil, restore the above state when exiting the minibuffer.
+This variable is let-bound to nil by functions that take care of
+the restoring themselves.")
+
 (defsubst ivy-set-action (action)
   "Set the current `ivy-last' field to ACTION."
   (setf (ivy-state-action ivy-last) action))
@@ -1013,6 +1020,10 @@ Example use:
               (funcall action x)
             (select-window (ivy--get-window ivy-last))
             (prog1 (with-current-buffer (ivy-state-buffer ivy-last)
+                     (when (and ivy-recursive-last
+                                ivy-recursive-restore
+                                (not (eq ivy-last ivy-recursive-last)))
+                       (ivy--reset-state (setq ivy-last ivy-recursive-last)))
                      (funcall action x))
               (unless (or (eq ivy-exit 'done)
                           (equal (selected-window)
@@ -1383,11 +1394,6 @@ Directories come first."
           (cl-remove-if-not predicate seq)
         seq))))
 
-(defvar ivy-recursive-restore t
-  "When non-nil, restore the above state when exiting the minibuffer.
-This variable is let-bound to nil by functions that take care of
-the restoring themselves.")
-
 ;;** Entry Point
 ;;;###autoload
 (cl-defun ivy-read (prompt collection
@@ -1472,7 +1478,7 @@ customizations apply to the current completion session."
                           (list (car source) (funcall (car source)))
                           ivy--extra-candidates))))))
       (setq ivy--extra-candidates '((original-source)))))
-  (let ((recursive-ivy-last (and (active-minibuffer-window) ivy-last))
+  (let ((ivy-recursive-last (and (active-minibuffer-window) ivy-last))
         (transformer-fn
          (plist-get ivy--display-transformers-list
                     (or caller (and (functionp collection)
@@ -1532,14 +1538,8 @@ customizations apply to the current completion session."
           (remove-hook 'post-command-hook #'ivy--exhibit)
           (ivy-overlay-cleanup)
           (when (setq unwind (ivy-state-unwind ivy-last))
-            (funcall unwind))
-          (unless (eq ivy-exit 'done)
-            (when recursive-ivy-last
-              (ivy--reset-state (setq ivy-last recursive-ivy-last)))))
+            (funcall unwind)))
       (ivy-call)
-      (when (and recursive-ivy-last
-                 ivy-recursive-restore)
-        (ivy--reset-state (setq ivy-last recursive-ivy-last)))
       (when (> (length (ivy-state-current ivy-last)) 0)
         (remove-text-properties 0 1 '(idx) (ivy-state-current ivy-last))))))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]