emacs-diffs
[Top][All Lists]
Advanced

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

master d5a7df8 4/4: Use directory-files-no-dot-files-regexp wherever pos


From: Mattias Engdegård
Subject: master d5a7df8 4/4: Use directory-files-no-dot-files-regexp wherever possible
Date: Thu, 16 Apr 2020 06:14:52 -0400 (EDT)

branch: master
commit d5a7df8c02f04102d50a5cd2290262f59f2b1415
Author: Mattias Engdegård <address@hidden>
Commit: Mattias Engdegård <address@hidden>

    Use directory-files-no-dot-files-regexp wherever possible
    
    Suggested by Paul Eggert.
    
    * lisp/files.el (directory-files-no-dot-files-regexp):
    Clarify semantics and purpose.
    * lisp/dired.el (dired-re-no-dot):
    Define as obsolete alias of directory-files-no-dot-files-regexp.
    (dired-delete-file):
    * lisp/gnus/gnus-util.el (gnus-delete-directory):
    * lisp/net/ange-ftp.el (ange-ftp-delete-directory):
    * lisp/obsolete/vc-arch.el (vc-arch-trim-revlib):
    * lisp/org/ob-core.el (org-babel-remove-temporary-directory):
    * lisp/vc/vc-rcs.el (vc-rcs-unregister):
    Use directory-files-no-dot-files-regexp.
---
 lisp/dired.el            |  8 +++++---
 lisp/files.el            |  5 ++++-
 lisp/gnus/gnus-util.el   |  2 +-
 lisp/gnus/gnus-uu.el     |  2 +-
 lisp/net/ange-ftp.el     |  3 +--
 lisp/obsolete/vc-arch.el | 11 ++++++-----
 lisp/org/ob-core.el      |  3 +--
 lisp/vc/vc-rcs.el        |  2 +-
 8 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/lisp/dired.el b/lisp/dired.el
index 9583d5d..14bbb28 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -3235,8 +3235,8 @@ Any other value means to ask for each directory."
                 (const :tag "Confirm for each top directory only" top))
   :group 'dired)
 
-;; Match anything but `.' and `..'.
-(defvar dired-re-no-dot (rx (or (not ".") "...")))
+(define-obsolete-variable-alias 'dired-re-no-dot
+  'directory-files-no-dot-files-regexp "28.1")
 
 ;; Delete file, possibly delete a directory and all its files.
 ;; This function is useful outside of dired.  One could change its name
@@ -3258,7 +3258,9 @@ TRASH non-nil means to trash the file instead of 
deleting, provided
        ;; but more efficient
        (if (not (eq t (car (file-attributes file))))
            (delete-file file trash)
-         (let* ((empty-dir-p (null (directory-files file t dired-re-no-dot))))
+         (let* ((empty-dir-p (null (directory-files
+                                    file t
+                                    directory-files-no-dot-files-regexp))))
            (if (and recursive (not empty-dir-p))
                (unless (eq recursive 'always)
                  (let ((prompt
diff --git a/lisp/files.el b/lisp/files.el
index 04c271d..b2b14e1 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -5754,7 +5754,10 @@ If called interactively, then PARENTS is non-nil."
 
 (defconst directory-files-no-dot-files-regexp
   "[^.]\\|\\.\\.\\."
-  "Regexp matching any file name except \".\" and \"..\".")
+  "Regexp matching any file name except \".\" and \"..\".
+More precisely, it matches parts of any nonempty string except those two.
+It is useful as the PATTERN argument to `directory-files' and
+`directory-files-and-attributes'.")
 
 (defun files--force (no-such fn &rest args)
   "Use NO-SUCH to affect behavior of function FN applied to list ARGS.
diff --git a/lisp/gnus/gnus-util.el b/lisp/gnus/gnus-util.el
index f0d328d..8d8956f 100644
--- a/lisp/gnus/gnus-util.el
+++ b/lisp/gnus/gnus-util.el
@@ -768,7 +768,7 @@ nil.  See also `gnus-bind-print-variables'."
 If there's no subdirectory, delete DIRECTORY as well."
   (when (file-directory-p directory)
     (let ((files (directory-files
-                 directory t (rx (or (not ".") "..."))))
+                 directory t directory-files-no-dot-files-regexp))
          file dir)
       (while files
        (setq file (pop files))
diff --git a/lisp/gnus/gnus-uu.el b/lisp/gnus/gnus-uu.el
index af37df0..70aeac0 100644
--- a/lisp/gnus/gnus-uu.el
+++ b/lisp/gnus/gnus-uu.el
@@ -1674,7 +1674,7 @@ Gnus might fail to display all of it.")
     did-unpack))
 
 (defun gnus-uu-dir-files (dir)
-  (let ((dirs (directory-files dir t (rx (or (not ".") "..."))))
+  (let ((dirs (directory-files dir t directory-files-no-dot-files-regexp))
        files file)
     (while dirs
       (if (file-directory-p (setq file (car dirs)))
diff --git a/lisp/net/ange-ftp.el b/lisp/net/ange-ftp.el
index bf20128..0cb8d7c 100644
--- a/lisp/net/ange-ftp.el
+++ b/lisp/net/ange-ftp.el
@@ -4169,8 +4169,7 @@ directory, so that Emacs will know its current contents."
               (if (file-directory-p file)
                   (ange-ftp-delete-directory file recursive trash)
                 (delete-file file trash)))
-            ;; We do not want to delete "." and "..".
-            (directory-files dir 'full (rx (or (not ".") "...")))))
+            (directory-files dir 'full directory-files-no-dot-files-regexp)))
        (if parsed
            (let* ((host (nth 0 parsed))
                   (user (nth 1 parsed))
diff --git a/lisp/obsolete/vc-arch.el b/lisp/obsolete/vc-arch.el
index bcdefac..93bd991 100644
--- a/lisp/obsolete/vc-arch.el
+++ b/lisp/obsolete/vc-arch.el
@@ -597,20 +597,21 @@ CALLBACK expects (ENTRIES &optional MORE-TO-COME); see
     (unless (file-writable-p rl-dir)
       (error "No writable revlib directory found"))
     (message "Revlib at %s" rl-dir)
-    (let* ((archives (directory-files rl-dir 'full (rx (or (not ".") "..."))))
+    (let* ((archives (directory-files rl-dir 'full
+                                      directory-files-no-dot-files-regexp))
            (categories
             (apply 'append
                    (mapcar (lambda (dir)
                              (when (file-directory-p dir)
-                               (directory-files dir 'full
-                                                (rx (or (not ".") "...")))))
+                               (directory-files
+                                dir 'full 
directory-files-no-dot-files-regexp)))
                            archives)))
            (branches
             (apply 'append
                    (mapcar (lambda (dir)
                              (when (file-directory-p dir)
-                               (directory-files dir 'full
-                                                (rx (or (not ".") "...")))))
+                               (directory-files
+                                dir 'full 
directory-files-no-dot-files-regexp)))
                            categories)))
            (versions
             (apply 'append
diff --git a/lisp/org/ob-core.el b/lisp/org/ob-core.el
index debc27c..fe9af1c 100644
--- a/lisp/org/ob-core.el
+++ b/lisp/org/ob-core.el
@@ -3053,9 +3053,8 @@ of `org-babel-temporary-directory'."
                  (if (eq t (car (file-attributes file)))
                      (delete-directory file)
                    (delete-file file)))
-               ;; We do not want to delete "." and "..".
                (directory-files org-babel-temporary-directory 'full
-                                 (rx (or (not ".") "..."))))
+                                 directory-files-no-dot-files-regexp))
          (delete-directory org-babel-temporary-directory))
       (error
        (message "Failed to remove temporary Org-babel directory %s"
diff --git a/lisp/vc/vc-rcs.el b/lisp/vc/vc-rcs.el
index 273f37c..23f088b 100644
--- a/lisp/vc/vc-rcs.el
+++ b/lisp/vc/vc-rcs.el
@@ -312,7 +312,7 @@ whether to remove it."
       (and (string= (file-name-nondirectory (directory-file-name dir)) "RCS")
           ;; check whether RCS dir is empty, i.e. it does not
           ;; contain any files except "." and ".."
-          (not (directory-files dir nil (rx (or (not ".") "..."))))
+          (not (directory-files dir nil directory-files-no-dot-files-regexp))
           (yes-or-no-p (format "Directory %s is empty; remove it? " dir))
           (delete-directory dir)))))
 



reply via email to

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