aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias EngdegÄrd2020-04-16 12:05:02 +0200
committerMattias EngdegÄrd2020-04-16 12:14:38 +0200
commitd5a7df8c02f04102d50a5cd2290262f59f2b1415 (patch)
tree6d0842717c72525cc866b9e6ad927a33288b26bd
parent7839390f271211882414f167e8e680b3154ee929 (diff)
downloademacs-d5a7df8c02f04102d50a5cd2290262f59f2b1415.tar.gz
emacs-d5a7df8c02f04102d50a5cd2290262f59f2b1415.zip
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.
-rw-r--r--lisp/dired.el8
-rw-r--r--lisp/files.el5
-rw-r--r--lisp/gnus/gnus-util.el2
-rw-r--r--lisp/gnus/gnus-uu.el2
-rw-r--r--lisp/net/ange-ftp.el3
-rw-r--r--lisp/obsolete/vc-arch.el11
-rw-r--r--lisp/org/ob-core.el3
-rw-r--r--lisp/vc/vc-rcs.el2
8 files changed, 20 insertions, 16 deletions
diff --git a/lisp/dired.el b/lisp/dired.el
index 9583d5d809e..14bbb28db52 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -3235,8 +3235,8 @@ Any other value means to ask for each directory."
3235 (const :tag "Confirm for each top directory only" top)) 3235 (const :tag "Confirm for each top directory only" top))
3236 :group 'dired) 3236 :group 'dired)
3237 3237
3238;; Match anything but `.' and `..'. 3238(define-obsolete-variable-alias 'dired-re-no-dot
3239(defvar dired-re-no-dot (rx (or (not ".") "..."))) 3239 'directory-files-no-dot-files-regexp "28.1")
3240 3240
3241;; Delete file, possibly delete a directory and all its files. 3241;; Delete file, possibly delete a directory and all its files.
3242;; This function is useful outside of dired. One could change its name 3242;; 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
3258 ;; but more efficient 3258 ;; but more efficient
3259 (if (not (eq t (car (file-attributes file)))) 3259 (if (not (eq t (car (file-attributes file))))
3260 (delete-file file trash) 3260 (delete-file file trash)
3261 (let* ((empty-dir-p (null (directory-files file t dired-re-no-dot)))) 3261 (let* ((empty-dir-p (null (directory-files
3262 file t
3263 directory-files-no-dot-files-regexp))))
3262 (if (and recursive (not empty-dir-p)) 3264 (if (and recursive (not empty-dir-p))
3263 (unless (eq recursive 'always) 3265 (unless (eq recursive 'always)
3264 (let ((prompt 3266 (let ((prompt
diff --git a/lisp/files.el b/lisp/files.el
index 04c271d7966..b2b14e1b90d 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -5754,7 +5754,10 @@ If called interactively, then PARENTS is non-nil."
5754 5754
5755(defconst directory-files-no-dot-files-regexp 5755(defconst directory-files-no-dot-files-regexp
5756 "[^.]\\|\\.\\.\\." 5756 "[^.]\\|\\.\\.\\."
5757 "Regexp matching any file name except \".\" and \"..\".") 5757 "Regexp matching any file name except \".\" and \"..\".
5758More precisely, it matches parts of any nonempty string except those two.
5759It is useful as the PATTERN argument to `directory-files' and
5760`directory-files-and-attributes'.")
5758 5761
5759(defun files--force (no-such fn &rest args) 5762(defun files--force (no-such fn &rest args)
5760 "Use NO-SUCH to affect behavior of function FN applied to list ARGS. 5763 "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 f0d328d334f..8d8956f1fb9 100644
--- a/lisp/gnus/gnus-util.el
+++ b/lisp/gnus/gnus-util.el
@@ -768,7 +768,7 @@ nil. See also `gnus-bind-print-variables'."
768If there's no subdirectory, delete DIRECTORY as well." 768If there's no subdirectory, delete DIRECTORY as well."
769 (when (file-directory-p directory) 769 (when (file-directory-p directory)
770 (let ((files (directory-files 770 (let ((files (directory-files
771 directory t (rx (or (not ".") "...")))) 771 directory t directory-files-no-dot-files-regexp))
772 file dir) 772 file dir)
773 (while files 773 (while files
774 (setq file (pop files)) 774 (setq file (pop files))
diff --git a/lisp/gnus/gnus-uu.el b/lisp/gnus/gnus-uu.el
index af37df07f97..70aeac00d7f 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.")
1674 did-unpack)) 1674 did-unpack))
1675 1675
1676(defun gnus-uu-dir-files (dir) 1676(defun gnus-uu-dir-files (dir)
1677 (let ((dirs (directory-files dir t (rx (or (not ".") "...")))) 1677 (let ((dirs (directory-files dir t directory-files-no-dot-files-regexp))
1678 files file) 1678 files file)
1679 (while dirs 1679 (while dirs
1680 (if (file-directory-p (setq file (car dirs))) 1680 (if (file-directory-p (setq file (car dirs)))
diff --git a/lisp/net/ange-ftp.el b/lisp/net/ange-ftp.el
index bf20128b612..0cb8d7cb837 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."
4169 (if (file-directory-p file) 4169 (if (file-directory-p file)
4170 (ange-ftp-delete-directory file recursive trash) 4170 (ange-ftp-delete-directory file recursive trash)
4171 (delete-file file trash))) 4171 (delete-file file trash)))
4172 ;; We do not want to delete "." and "..". 4172 (directory-files dir 'full directory-files-no-dot-files-regexp)))
4173 (directory-files dir 'full (rx (or (not ".") "...")))))
4174 (if parsed 4173 (if parsed
4175 (let* ((host (nth 0 parsed)) 4174 (let* ((host (nth 0 parsed))
4176 (user (nth 1 parsed)) 4175 (user (nth 1 parsed))
diff --git a/lisp/obsolete/vc-arch.el b/lisp/obsolete/vc-arch.el
index bcdefac5187..93bd991eb3a 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
597 (unless (file-writable-p rl-dir) 597 (unless (file-writable-p rl-dir)
598 (error "No writable revlib directory found")) 598 (error "No writable revlib directory found"))
599 (message "Revlib at %s" rl-dir) 599 (message "Revlib at %s" rl-dir)
600 (let* ((archives (directory-files rl-dir 'full (rx (or (not ".") "...")))) 600 (let* ((archives (directory-files rl-dir 'full
601 directory-files-no-dot-files-regexp))
601 (categories 602 (categories
602 (apply 'append 603 (apply 'append
603 (mapcar (lambda (dir) 604 (mapcar (lambda (dir)
604 (when (file-directory-p dir) 605 (when (file-directory-p dir)
605 (directory-files dir 'full 606 (directory-files
606 (rx (or (not ".") "..."))))) 607 dir 'full directory-files-no-dot-files-regexp)))
607 archives))) 608 archives)))
608 (branches 609 (branches
609 (apply 'append 610 (apply 'append
610 (mapcar (lambda (dir) 611 (mapcar (lambda (dir)
611 (when (file-directory-p dir) 612 (when (file-directory-p dir)
612 (directory-files dir 'full 613 (directory-files
613 (rx (or (not ".") "..."))))) 614 dir 'full directory-files-no-dot-files-regexp)))
614 categories))) 615 categories)))
615 (versions 616 (versions
616 (apply 'append 617 (apply 'append
diff --git a/lisp/org/ob-core.el b/lisp/org/ob-core.el
index debc27cfbff..fe9af1ce602 100644
--- a/lisp/org/ob-core.el
+++ b/lisp/org/ob-core.el
@@ -3053,9 +3053,8 @@ of `org-babel-temporary-directory'."
3053 (if (eq t (car (file-attributes file))) 3053 (if (eq t (car (file-attributes file)))
3054 (delete-directory file) 3054 (delete-directory file)
3055 (delete-file file))) 3055 (delete-file file)))
3056 ;; We do not want to delete "." and "..".
3057 (directory-files org-babel-temporary-directory 'full 3056 (directory-files org-babel-temporary-directory 'full
3058 (rx (or (not ".") "...")))) 3057 directory-files-no-dot-files-regexp))
3059 (delete-directory org-babel-temporary-directory)) 3058 (delete-directory org-babel-temporary-directory))
3060 (error 3059 (error
3061 (message "Failed to remove temporary Org-babel directory %s" 3060 (message "Failed to remove temporary Org-babel directory %s"
diff --git a/lisp/vc/vc-rcs.el b/lisp/vc/vc-rcs.el
index 273f37c10d6..23f088b0cff 100644
--- a/lisp/vc/vc-rcs.el
+++ b/lisp/vc/vc-rcs.el
@@ -312,7 +312,7 @@ whether to remove it."
312 (and (string= (file-name-nondirectory (directory-file-name dir)) "RCS") 312 (and (string= (file-name-nondirectory (directory-file-name dir)) "RCS")
313 ;; check whether RCS dir is empty, i.e. it does not 313 ;; check whether RCS dir is empty, i.e. it does not
314 ;; contain any files except "." and ".." 314 ;; contain any files except "." and ".."
315 (not (directory-files dir nil (rx (or (not ".") "...")))) 315 (not (directory-files dir nil directory-files-no-dot-files-regexp))
316 (yes-or-no-p (format "Directory %s is empty; remove it? " dir)) 316 (yes-or-no-p (format "Directory %s is empty; remove it? " dir))
317 (delete-directory dir))))) 317 (delete-directory dir)))))
318 318