From: Eli Zaretskii <eliz@gnu.org>
To: chad <yandros@gmail.com>
Cc: larsi@gnus.org, 55877@debbugs.gnu.org
Subject: bug#55877: 29.0.50; list-directory doesn't allow globbing interactively
Date: Sat, 11 Jun 2022 19:55:41 +0300 [thread overview]
Message-ID: <831qvvxhpu.fsf@gnu.org> (raw)
In-Reply-To: <CAO2hHWYbZX=XqOXYsiJEKgrjbftPy-K02qkDsznORWFb4wK5vQ@mail.gmail.com> (message from chad on Sat, 11 Jun 2022 12:38:53 -0400)
> Cc: 55877@debbugs.gnu.org
> From: chad <yandros@gmail.com>
> Date: Sat, 11 Jun 2022 12:38:53 -0400
>
> Sorry, I was probably unclear, and my earlier hack-around was no good. The first call to list-directory works
> fine. It's the followup, issued from the buffer of the first, that raises the problem, because default-directory in
> the buffer of the first call is set to, in your example, /tmp/*/, and call-process balks when default-directory
> doesn't exist. To repeat, from a fresh emacs -Q:
>
> `C-x C-d /tmp/*/ RET C-x 0 C-x C-d /tmp/ RET'.
>
> I see "insert-directory: Setting current directory: No such file or directory, /tmp/*/" in *Messages* in emacs
> -Q. (In practice, with a fresh emacs -Q, sometimes I also get the same error from
> comp-run-async-workers, if it triggers when I'm in that buffer, which was a surprise.)
>
> I suspect this is due to the explicit setting of default-directory at the end of list-directory:
>
> > ;; Finishing with-output-to-temp-buffer seems to clobber default-directory.
> > (with-current-buffer buffer
> > (setq default-directory
> > (if (file-directory-p dirname)
> > (file-name-as-directory dirname)
> > (file-name-directory dirname))))
>
> In the above test case, dirname ends up as "/tmp/*/", which falls through file-directory-p and ends up passed
> to file-name-directory, which just returns it unchanged under unix, because of the trailing slash. This is a
> mirror to the logic up-function that checks for wildcards (insert-directory-wildcard-in-dir-p, etc). I considered
> ways to pass down that information or recreate it, but I don't (yet?) have a better answer for what value it
> should have than "something safe" or "try to munge the wildcard into an existing directory", which seems
> terrible. Maybe the right answer is to not setq default-directory at all unless dirname is file-directory-p?
Does the below fix the problem?
diff --git a/lisp/files.el b/lisp/files.el
index 75a856c..aacc1cd 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -7406,9 +7406,9 @@ list-directory
;; Finishing with-output-to-temp-buffer seems to clobber default-directory.
(with-current-buffer buffer
(setq default-directory
- (if (file-directory-p dirname)
+ (if (file-accessible-directory-p dirname)
(file-name-as-directory dirname)
- (file-name-directory dirname))))))
+ (file-name-directory (directory-file-name dirname)))))))
(defun shell-quote-wildcard-pattern (pattern)
"Quote characters special to the shell in PATTERN, leave wildcards alone.
next prev parent reply other threads:[~2022-06-11 16:55 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-09 18:56 bug#55877: 29.0.50; list-directory doesn't allow globbing interactively chad
2022-06-09 19:20 ` Drew Adams
2022-06-09 20:07 ` Lars Ingebrigtsen
2022-06-10 8:22 ` Lars Ingebrigtsen
2022-06-10 21:04 ` chad
2022-06-11 1:31 ` chad
2022-06-11 11:02 ` Lars Ingebrigtsen
2022-06-11 16:38 ` chad
2022-06-11 16:55 ` Eli Zaretskii [this message]
2022-06-11 17:03 ` chad
2022-06-11 17:05 ` Eli Zaretskii
2022-06-12 9:59 ` Lars Ingebrigtsen
2022-06-12 10:04 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=831qvvxhpu.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=55877@debbugs.gnu.org \
--cc=larsi@gnus.org \
--cc=yandros@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).