]> code.delx.au - gnu-emacs-elpa/commitdiff
Move read-file-name to :display-transformer-fn
authorOleh Krehel <ohwoeowho@gmail.com>
Sat, 27 Feb 2016 12:48:11 +0000 (13:48 +0100)
committerOleh Krehel <ohwoeowho@gmail.com>
Sat, 27 Feb 2016 12:48:11 +0000 (13:48 +0100)
* ivy.el (ivy-set-display-transformer): Set 'read-file-name-internal to
  'ivy-read-file-transformer.
(ivy-read-file-transformer): New defun.
(ivy--format): Simplify.

ivy.el

diff --git a/ivy.el b/ivy.el
index d500b8e9e667b224ce6d331d289927734903cae7..976733244ccfd9e89a81b737b9ec7f30569ba722 100644 (file)
--- a/ivy.el
+++ b/ivy.el
@@ -2387,6 +2387,14 @@ SEPARATOR is used to join the candidates."
                  (cl-incf i))))))
     str))
 
+(ivy-set-display-transformer
+ 'read-file-name-internal 'ivy-read-file-transformer)
+
+(defun ivy-read-file-transformer (str)
+  (if (string-match-p "/\\'" str)
+      (propertize str 'face 'ivy-subdir)
+    str))
+
 (defun ivy--format (cands)
   "Return a string for CANDS suitable for display in the minibuffer.
 CANDS is a list of strings."
@@ -2402,12 +2410,6 @@ CANDS is a list of strings."
            (cands (cl-subseq cands start end))
            (index (- ivy--index start))
            transformer-fn)
-      (cond (ivy--directory
-             (setq cands (mapcar (lambda (x)
-                                   (if (string-match-p "/\\'" x)
-                                       (propertize x 'face 'ivy-subdir)
-                                     x))
-                                 cands))))
       (setq ivy--current (copy-sequence (nth index cands)))
       (when (setq transformer-fn (ivy-state-display-transformer-fn ivy-last))
         (with-ivy-window