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

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

[elpa] master ebac0e9 352/399: ivy.el (ivy--compute-extra-actions): Extr


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

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

    ivy.el (ivy--compute-extra-actions): Extract
    
    Re #2121
---
 ivy.el | 38 +++++++++++++++++++++-----------------
 1 file changed, 21 insertions(+), 17 deletions(-)

diff --git a/ivy.el b/ivy.el
index 118d346..dcecffe 100644
--- a/ivy.el
+++ b/ivy.el
@@ -323,6 +323,26 @@ ACTIONS that have the same key."
                     (append (plist-get ivy--actions-list cmd) actions)
                     :key #'car :test #'equal))))
 
+(defun ivy--compute-extra-actions (action caller)
+  "Add extra actions to ACTION based on CALLER."
+  (let ((extra-actions (cl-delete-duplicates
+                        (append (plist-get ivy--actions-list t)
+                                (plist-get ivy--actions-list this-command)
+                                (plist-get ivy--actions-list caller))
+                        :key #'car :test #'equal)))
+    (if extra-actions
+        (cond ((functionp action)
+               `(1
+                 ("o" ,action "default")
+                 ,@extra-actions))
+              ((null action)
+               `(1
+                 ("o" identity "default")
+                 ,@extra-actions))
+              (t
+               (delete-dups (append action extra-actions))))
+      action)))
+
 (defvar ivy--prompts-list nil)
 
 (defun ivy-set-prompt (caller prompt-fn)
@@ -1937,23 +1957,7 @@ candidates is updated after each input by calling 
COLLECTION.
 CALLER is a symbol to uniquely identify the caller to `ivy-read'.
 It is used, along with COLLECTION, to determine which
 customizations apply to the current completion session."
-  (let ((extra-actions (cl-delete-duplicates
-                        (append (plist-get ivy--actions-list t)
-                                (plist-get ivy--actions-list this-command)
-                                (plist-get ivy--actions-list caller))
-                        :key #'car :test #'equal)))
-    (when extra-actions
-      (setq action
-            (cond ((functionp action)
-                   `(1
-                     ("o" ,action "default")
-                     ,@extra-actions))
-                  ((null action)
-                   `(1
-                     ("o" identity "default")
-                     ,@extra-actions))
-                  (t
-                   (delete-dups (append action extra-actions)))))))
+  (setq action (ivy--compute-extra-actions action caller))
   (setq ivy-marked-candidates nil)
   (unless caller
     (setq caller this-command))



reply via email to

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