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.
(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
;; 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
(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.
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))
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)))
(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))
(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
(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"
(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)))))