[Top][All Lists]

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

[elpa] master 7925637 353/399: ivy.el (ivy--compute-extra-candidates): E

From: Oleh Krehel
Subject: [elpa] master 7925637 353/399: ivy.el (ivy--compute-extra-candidates): Extract
Date: Sat, 20 Jul 2019 14:57:58 -0400 (EDT)

branch: master
commit 79256375ad0879c81741289ca5225561cdc5c11c
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    ivy.el (ivy--compute-extra-candidates): Extract
    Re #2121
 ivy.el | 29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/ivy.el b/ivy.el
index dcecffe..da06c38 100644
--- a/ivy.el
+++ b/ivy.el
@@ -392,6 +392,17 @@ Example:
   (setq ivy--sources-list
         (plist-put ivy--sources-list cmd sources)))
+(defun ivy--compute-extra-candidates (caller)
+  (let ((extra-sources (or (plist-get ivy--sources-list caller)
+                           '((original-source))))
+        (result nil))
+    (dolist (source extra-sources)
+      (cond ((equal source '(original-source))
+             (push source result))
+            ((null (cdr source))
+             (push (list (car source) (funcall (car source))) result))))
+    result))
 (defvar ivy-current-prefix-arg nil
   "Prefix arg to pass to actions.
 This is a global variable that is set by ivy functions for use in
@@ -1958,23 +1969,9 @@ CALLER is a symbol to uniquely identify the caller to 
 It is used, along with COLLECTION, to determine which
 customizations apply to the current completion session."
   (setq action (ivy--compute-extra-actions action caller))
+  (setq caller (or caller this-command))
+  (setq ivy--extra-candidates (ivy--compute-extra-candidates caller))
   (setq ivy-marked-candidates nil)
-  (unless caller
-    (setq caller this-command))
-  (let ((extra-sources (plist-get ivy--sources-list caller)))
-    (if extra-sources
-        (progn
-          (setq ivy--extra-candidates nil)
-          (dolist (source extra-sources)
-            (cond ((equal source '(original-source))
-                   (setq ivy--extra-candidates
-                         (cons source ivy--extra-candidates)))
-                  ((null (cdr source))
-                   (setq ivy--extra-candidates
-                         (cons
-                          (list (car source) (funcall (car source)))
-                          ivy--extra-candidates))))))
-      (setq ivy--extra-candidates '((original-source)))))
   (let* ((ivy-recursive-last (and (active-minibuffer-window) ivy-last))
           (plist-get ivy--display-transformers-list

reply via email to

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