From ec3b6fa8e18a64616af057195f86a4c8b09f9ccd Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Wed, 1 Dec 2021 20:16:29 +0100 Subject: [PATCH] Make `C-x C-d' require either an existing directory or a wildcard * lisp/files.el (list-directory): Require either an existing directory or a wildcard (bug#25807). --- lisp/files.el | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lisp/files.el b/lisp/files.el index f72723ab7dd..c96e79cc63d 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -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) -- 2.39.2