From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: chad Newsgroups: gmane.emacs.bugs Subject: bug#55877: 29.0.50; list-directory doesn't allow globbing interactively Date: Sat, 11 Jun 2022 12:38:53 -0400 Message-ID: References: <87ilp9y518.fsf@gnus.org> <87edzxx711.fsf@gnus.org> <87h74rsbtg.fsf@gnus.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000006d719805e12eb174" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40553"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 55877@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jun 11 18:40:32 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 1o04A4-000APL-1P for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 11 Jun 2022 18:40:32 +0200 Original-Received: from localhost ([::1]:37664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o04A2-0005AL-O4 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 11 Jun 2022 12:40:30 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41350) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o049b-0005A8-9T for bug-gnu-emacs@gnu.org; Sat, 11 Jun 2022 12:40:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:59904) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o049a-0003jb-Rc for bug-gnu-emacs@gnu.org; Sat, 11 Jun 2022 12:40:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1o049a-0000pN-Kf for bug-gnu-emacs@gnu.org; Sat, 11 Jun 2022 12:40:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: chad Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 11 Jun 2022 16:40:02 +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.16549655643121 (code B ref 55877); Sat, 11 Jun 2022 16:40:02 +0000 Original-Received: (at 55877) by debbugs.gnu.org; 11 Jun 2022 16:39:24 +0000 Original-Received: from localhost ([127.0.0.1]:53801 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o048w-0000oF-VE for submit@debbugs.gnu.org; Sat, 11 Jun 2022 12:39:24 -0400 Original-Received: from mail-lf1-f51.google.com ([209.85.167.51]:41768) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o048l-0000nq-Gj for 55877@debbugs.gnu.org; Sat, 11 Jun 2022 12:39:21 -0400 Original-Received: by mail-lf1-f51.google.com with SMTP id 20so2858590lfz.8 for <55877@debbugs.gnu.org>; Sat, 11 Jun 2022 09:39:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=H1ngTpidJKpdYUTT8/i/fUEDswx8IKlsUUSA02XaoEQ=; b=LZIWz6hsML9J0IK1nyD0PUICuzEj9QyMPDDCOU4u8by+fG/jlntSuslr7iOc5L6kSl /tM6suKNItvZm6H3XuktTvzbOdKYJyd6Qtu9DnuaGaGBQp/3oHCoRhVCy8hIWcS4OYKL 17kZZL+h9FYDwp+yS3jrpfBcCyc7hZQUqEuGFRZ0/Mt7M+gH7A0SkrEJ0P+0gR/2jySu YMfjeB4Qgw92u77I98mbedMZzP0xnV92MbyQtTAUMrnwNAgVQ2zgwjoJJGMR1y/DPbKB UmfOPjTkvfdJ5Mov8E17wRfkcWbNsa/+mGT8pXMqTm7QS+y5fI3/qCZIuAf+eN4J/JnE t3JA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=H1ngTpidJKpdYUTT8/i/fUEDswx8IKlsUUSA02XaoEQ=; b=pLElrOeP45vBpnoPap5IQVQlyZmYBjSGaEic7qJ1aRZIdns92jaNhtp4xlC1h7ncwE hcq50yIOWNwLv8U7N5HMrNl+Tugp8zmQnHFI8z3y9YkY1vMk1XPNzfQK0u7Qo3abgTGg CWmfOhgp6Vcm42B6yU23ZLs06kQoghSjtiI9UNI94OqHMu5wvYQMABTpBq+10+mNwyeq 9SwjoPy+tUrmwfo0/sOq0Dy5DOh4zyExdy/IDVWICG5j8TGKQdL70nkpgYNfK38TER6o eHErxHln8I2oVDem5Uhjfn7Ah9TUfOsp2YuuxyeOVx3ntOtY9M9nkRGiaKjlroRysP6M s6Kw== X-Gm-Message-State: AOAM532PXdPbYIUJn2t5HFhnh+d/iScQVSReFFkm4FRhnfPgyEFs+qZo DPROWRyEP2IIrPMJBwdOyiDgAapz7n9FI2H0wWo= X-Google-Smtp-Source: ABdhPJyssFRM0YedB1gYTVvHp9898KV4xaYHER0gtSWpg5U5tMT+UOJQ4DlINcy/ti1oYjWBaxEJCk4FfS8jgln5nU0= X-Received: by 2002:a05:6512:b8e:b0:478:f926:1d01 with SMTP id b14-20020a0565120b8e00b00478f9261d01mr32271389lfv.151.1654965545036; Sat, 11 Jun 2022 09:39:05 -0700 (PDT) In-Reply-To: <87h74rsbtg.fsf@gnus.org> 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:234295 Archived-At: --0000000000006d719805e12eb174 Content-Type: text/plain; charset="UTF-8" On Sat, Jun 11, 2022 at 7:02 AM Lars Ingebrigtsen wrote: > chad writes: > > > I thought I saw an error here when list-directory with a directory (not > file) glob (ex: ~ > > /Project/emacs/*/) is followed by another list-directory, but I think > the actual issue is > > that the default directory in the first case is set to something that > doesn't exist, which > > messes up call-process in the second invocation of list-directory. The > error I saw was: > >[...] > I'm unable to reproduce this -- if I say `C-x C-d /tmp/*/ RET' it works > fine for me... > 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? Thanks, ~Chad --0000000000006d719805e12eb174 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Sat, Jun 11, 2022 at 7:02 AM Lars = Ingebrigtsen <larsi@gnus.org> w= rote:
chad <<= a href=3D"mailto:yandros@gmail.com" target=3D"_blank">yandros@gmail.com= > writes:

> I thought I saw an error here when list-directory with a directory (no= t file) glob (ex: ~
> /Project/emacs/*/) is followed by another list-directory, but I think = the actual issue is
> that the default directory in the first case is set to something that = doesn't exist, which
> messes up call-process in the second invocation of list-directory. The= error I saw was:
>[...]
I'm unable to reproduce this -- if I say `C-x C-d /tmp/*/ RET' it w= orks
fine for me...

Sorry, I was probably un= clear, and my earlier hack-around was no good. The first call to list-direc= tory 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 f= irst call is set to, in your example, /tmp/*/, and call-process balks when = default-directory doesn't exist.=C2=A0 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 d= irectory: 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, w= hich was a surprise.)=C2=A0

I suspect this is due = to the explicit setting of default-directory at the end of list-directory:<= /div>

>=C2=A0 =C2=A0 ;; Finishing with-output-to-temp= -buffer seems to clobber default-directory.
> =C2=A0 =C2=A0(with-cu= rrent-buffer buffer
> =C2=A0 =C2=A0 =C2=A0 (setq default-directory> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (if (file-directory-= p dirname)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0(file-name-as-directory dirname)
>=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (file-name-directory dirname))))<= /div>

In the= above test case, dirname ends up as "/tmp/*/", which falls throu= gh file-directory-p and ends up passed to file-name-directory, which just r= eturns it unchanged under unix, because of the trailing slash. This is a mi= rror to the logic up-function that checks for wildcards (insert-directory-w= ildcard-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 wildc= ard into an existing directory", which seems terrible. Maybe the right= answer is to not setq default-directory at all unless dirname is file-dire= ctory-p?

Thanks,
~Chad
--0000000000006d719805e12eb174--