[Top][All Lists]

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

[elpa] master 0fd6a75 142/272: Move switch-to-buffer to :display-transfo

From: Oleh Krehel
Subject: [elpa] master 0fd6a75 142/272: Move switch-to-buffer to :display-transformer-fn
Date: Mon, 25 Apr 2016 10:13:22 +0000

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

    Move switch-to-buffer to :display-transformer-fn
    * ivy.el (ivy-read): Use also COLLECTION as a key for
    (ivy--format): Simplify.
    (ivy-switch-buffer-transformer): New defun.
    (ivy-set-display-transformer): Set 'ivy-switch-buffer and
    'internal-complete-buffer to 'ivy-switch-buffer-transformer.
 ivy.el |   27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/ivy.el b/ivy.el
index fe840c7..d500b8e 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1259,7 +1259,10 @@ customizations apply to the current completion session."
       (setq ivy--extra-candidates '((original-source)))))
   (let ((recursive-ivy-last (and (active-minibuffer-window) ivy-last))
-        (transformer-fn (plist-get ivy--display-transformers-list caller)))
+        (transformer-fn
+         (plist-get ivy--display-transformers-list
+                    (or caller (and (functionp collection)
+                                    collection)))))
     (setq ivy-last
            :prompt prompt
@@ -2404,15 +2407,6 @@ CANDS is a list of strings."
                                    (if (string-match-p "/\\'" x)
                                        (propertize x 'face 'ivy-subdir)
-                                 cands)))
-            ((eq (ivy-state-collection ivy-last) 'internal-complete-buffer)
-             (setq cands (mapcar (lambda (x)
-                                   (let ((b (get-buffer x)))
-                                     (if (and b
-                                              (buffer-file-name b)
-                                              (buffer-modified-p b))
-                                         (propertize x 'face 
-                                       x)))
       (setq ivy--current (copy-sequence (nth index cands)))
       (when (setq transformer-fn (ivy-state-display-transformer-fn ivy-last))
@@ -2555,6 +2549,19 @@ Skip buffers that match `ivy-ignore-buffers'."
+ 'ivy-switch-buffer 'ivy-switch-buffer-transformer)
+ 'internal-complete-buffer 'ivy-switch-buffer-transformer)
+(defun ivy-switch-buffer-transformer (str)
+  (let ((b (get-buffer str)))
+    (if (and b
+             (buffer-file-name b)
+             (buffer-modified-p b))
+        (propertize str 'face 'ivy-modified-buffer)
+      str)))
 (defun ivy-switch-buffer ()
   "Switch to another buffer."

reply via email to

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