emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master ba59181: Fix problem with files like "~" in `direct


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] master ba59181: Fix problem with files like "~" in `directory-files-recursively'
Date: Wed, 10 Jul 2019 08:04:13 -0400 (EDT)

branch: master
commit ba59181c41a4685b595200306c6585a004c41e26
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    Fix problem with files like "~" in `directory-files-recursively'
    
    * lisp/files.el (directory-files-recursively): Don't bug out on
    files like "~" that have special meaning to `expand-file-name'
    (bug#36490).
---
 lisp/files.el | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/lisp/files.el b/lisp/files.el
index e8a44af..b2249bf 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -819,17 +819,18 @@ order, and files from each directory are sorted in 
alphabetical order.
 Each file name appears in the returned list in its absolute form.
 Optional argument INCLUDE-DIRECTORIES non-nil means also include in the
 output directories whose names match REGEXP."
-  (let ((result nil)
-       (files nil)
-       ;; When DIR is "/", remote file names like "/method:" could
-       ;; also be offered.  We shall suppress them.
-       (tramp-mode (and tramp-mode (file-remote-p (expand-file-name dir)))))
+  (let* ((result nil)
+        (files nil)
+         (dir (directory-file-name dir))
+        ;; When DIR is "/", remote file names like "/method:" could
+        ;; also be offered.  We shall suppress them.
+        (tramp-mode (and tramp-mode (file-remote-p (expand-file-name dir)))))
     (dolist (file (sort (file-name-all-completions "" dir)
                        'string<))
       (unless (member file '("./" "../"))
        (if (directory-name-p file)
            (let* ((leaf (substring file 0 (1- (length file))))
-                  (full-file (expand-file-name leaf dir)))
+                  (full-file (concat dir "/" leaf)))
              ;; Don't follow symlinks to other directories.
              (unless (file-symlink-p full-file)
                (setq result
@@ -839,7 +840,7 @@ output directories whose names match REGEXP."
                         (string-match regexp leaf))
                (setq result (nconc result (list full-file)))))
          (when (string-match regexp file)
-           (push (expand-file-name file dir) files)))))
+           (push (concat dir "/" file) files)))))
     (nconc result (nreverse files))))
 
 (defvar module-file-suffix)



reply via email to

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