branch: master
commit 17497218646cb91eaaa6d623076d1764f2d4f3d7
Author: Basil L. Contovounesios <[email protected]>
Commit: Oleh Krehel <[email protected]>

    ivy.el (ivy--dirname-p): New function
    
    Provide compatibility shim for Emacs 25 function directory-name-p.
    
    Fixes #1317
---
 ivy.el | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/ivy.el b/ivy.el
index dee2a46..ca80da4 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1471,6 +1471,13 @@ like.")
   "Sorting won't be done for collections larger than this."
   :type 'integer)
 
+(defalias 'ivy--dirname-p
+  (if (fboundp 'directory-name-p)
+      #'directory-name-p
+    (lambda (name)
+      "Return non-nil if NAME ends with a directory separator."
+      (string-match-p "/\\'" name))))
+
 (defun ivy--sorted-files (dir)
   "Return the list of files in DIR.
 Directories come first."
@@ -1487,7 +1494,7 @@ Directories come first."
       (when (eq (setq sort-fn (ivy--sort-function 'read-file-name-internal))
                 #'ivy-sort-file-function-default)
         (setq seq (mapcar (lambda (x)
-                            (propertize x 'dirp (string-match-p "/\\'" x)))
+                            (propertize x 'dirp (ivy--dirname-p x)))
                           seq)))
       (when sort-fn
         (setq seq (cl-sort seq sort-fn)))
@@ -3243,7 +3250,7 @@ FACE is the face to apply to STR."
 
 (defun ivy-read-file-transformer (str)
   "Transform candidate STR when reading files."
-  (if (string-match-p "/\\'" str)
+  (if (ivy--dirname-p str)
       (propertize str 'face 'ivy-subdir)
     str))
 

Reply via email to