]> git.eshelyaron.com Git - emacs.git/commitdiff
Make `C-x C-d' require either an existing directory or a wildcard
authorLars Ingebrigtsen <larsi@gnus.org>
Wed, 1 Dec 2021 19:16:29 +0000 (20:16 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Wed, 1 Dec 2021 19:16:57 +0000 (20:16 +0100)
* lisp/files.el (list-directory): Require either an existing
directory or a wildcard (bug#25807).

lisp/files.el

index f72723ab7dd2d31cf41030e5e0c055440ac0dc98..c96e79cc63d460546e7a69cf21ab044ea72dae52 100644 (file)
@@ -7211,11 +7211,18 @@ DIRNAME is globbed by the shell if necessary.
 Prefix arg (second arg if noninteractive) means supply -l switch to `ls'.
 Actions controlled by variables `list-directory-brief-switches'
 and `list-directory-verbose-switches'."
-  (interactive (let ((pfx current-prefix-arg))
-                (list (read-directory-name (if pfx "List directory (verbose): "
-                                        "List directory (brief): ")
-                                      nil default-directory nil)
-                      pfx)))
+  (interactive
+   (let ((pfx current-prefix-arg))
+     (list (read-file-name
+            (if pfx "List directory (verbose): "
+             "List directory (brief): ")
+           nil default-directory t
+            nil
+            (lambda (file)
+              (or (file-directory-p file)
+                  (insert-directory-wildcard-in-dir-p
+                   (expand-file-name file)))))
+           pfx)))
   (let ((switches (if verbose list-directory-verbose-switches
                    list-directory-brief-switches))
        buffer)