From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#55877: 29.0.50; list-directory doesn't allow globbing interactively Date: Sat, 11 Jun 2022 19:55:41 +0300 Message-ID: <831qvvxhpu.fsf@gnu.org> References: <87ilp9y518.fsf@gnus.org> <87edzxx711.fsf@gnus.org> <87h74rsbtg.fsf@gnus.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38077"; mail-complaints-to="usenet@ciao.gmane.io" Cc: larsi@gnus.org, 55877@debbugs.gnu.org To: chad Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jun 11 18:57:14 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o04QC-0009mA-5d for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 11 Jun 2022 18:57:12 +0200 Original-Received: from localhost ([::1]:42648 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o04QA-00013q-Ul for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 11 Jun 2022 12:57:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43506) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o04Q2-00013d-1J for bug-gnu-emacs@gnu.org; Sat, 11 Jun 2022 12:57:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:59920) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o04Q1-0006KL-P2 for bug-gnu-emacs@gnu.org; Sat, 11 Jun 2022 12:57:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1o04Q1-0001Hx-Nl for bug-gnu-emacs@gnu.org; Sat, 11 Jun 2022 12:57:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 11 Jun 2022 16:57:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55877 X-GNU-PR-Package: emacs Original-Received: via spool by 55877-submit@debbugs.gnu.org id=B55877.16549665634878 (code B ref 55877); Sat, 11 Jun 2022 16:57:01 +0000 Original-Received: (at 55877) by debbugs.gnu.org; 11 Jun 2022 16:56:03 +0000 Original-Received: from localhost ([127.0.0.1]:53817 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o04P5-0001Gb-8z for submit@debbugs.gnu.org; Sat, 11 Jun 2022 12:56:03 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:58424) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o04P3-0001G3-Fw for 55877@debbugs.gnu.org; Sat, 11 Jun 2022 12:56:01 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:58486) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o04Oy-0006El-2O; Sat, 11 Jun 2022 12:55:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=cTu/4cA91JgPiZsKKRF3fo/E7E/d39AbdcGQZZJFaiU=; b=RIfhu+od6y+X ztk7k4f92Nw5pU6IXcHhtn/zaLRfAN8UgFopEcx7Cti69QMMYRGZKYrV/6hRfKIFHBJNTdXVELOSp HoJrRw7sc5ZGX8elBBdFyJwjEQkT/DgB+wFyLybarC6KotGd91g6g8Qv7jStrIhCY0N8KmiKTFcJ2 /qlKDuGDk+EhXXnY8YLTrxmNoC9h5Wp8hmnDrSf93XvNCRornaLcIdNdlfSyVB/MsIU+36ZLJHZFo fI2jkXz0csbc8WpFnhok03NtwMCrpfD9uc5qY6TDZwNqlsDBhrOVDHAEHssNHQ71tDlNN4I33T75u Xk6PIxwuEnFTNkzR97pPZg==; Original-Received: from [87.69.77.57] (port=1716 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o04Ox-0002xR-IX; Sat, 11 Jun 2022 12:55:55 -0400 In-Reply-To: (message from chad on Sat, 11 Jun 2022 12:38:53 -0400) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:234297 Archived-At: > Cc: 55877@debbugs.gnu.org > From: chad > 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.