GNU bug report logs - #58784
28.2; project-buffers incorrect under let-bound default-directory

Previous Next

Package: emacs;

Reported by: Sean Devlin <spd <at> toadstyle.org>

Date: Wed, 26 Oct 2022 00:14:01 UTC

Severity: normal

Found in version 28.2

Done: Dmitry Gutov <dgutov <at> yandex.ru>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 58784 in the body.
You can then email your comments to 58784 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#58784; Package emacs. (Wed, 26 Oct 2022 00:14:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Sean Devlin <spd <at> toadstyle.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 26 Oct 2022 00:14:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Sean Devlin <spd <at> toadstyle.org>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.2; project-buffers incorrect under let-bound default-directory
Date: Tue, 25 Oct 2022 20:13:36 -0400
Hi folks,

The project.el function project-buffers can return incorrect results
when invoked while a let-binding for default-directory is in
effect. This is because project-buffers (both the default and vc-based
implementations) does its work by inspecting the local value of
default-directory in each buffer, and the let-binding temporarily
affects this value.

To see this in action, start emacs with -Q and evaluate the following
forms in order:

(require 'project)

(find-file-noselect "/tmp/tmpfile")
(setq my-project '(transient . "/tmp/"))

;; just the tmpfile
(project-buffers my-project)

;; both tmpfile and scratch
(let ((default-directory "/tmp/"))
  (project-buffers my-project))

In the last form, project-buffers includes the current buffer (i.e. the
scratch buffer in our example) with the results. (This is true even if
the current buffer is visiting a file in some unrelated directory.)

This matters because the command project-switch-project let-binds
default-directory before calling project-switch-commands. This means
that if you set project-switch-commands to some function that calls
project-buffers, you will get incorrect results.

For example, evaluate the following forms in order:

(defun my-list-project-buffers ()
  "List the current project's buffers."
  (interactive)
  (let ((buffer-list (project-buffers (project-current t)))
	(buffer-name (project-prefixed-buffer-name "my-project-buffer-list")))
    (with-current-buffer (get-buffer-create buffer-name)
      (erase-buffer)
      (save-excursion
	(dolist (buffer buffer-list)
	  (insert (buffer-name buffer))
	  (insert ?\n))))
    (switch-to-buffer buffer-name)))

(setq project-switch-commands #'my-list-project-buffers)

;; list tmpfile but also scratch
(project-switch-project "/tmp/")

In GNU Emacs 28.2
System Description:  macOS

Configured using:
'configure --disable-silent-rules
--enable-locallisppath=/opt/homebrew/share/emacs/site-lisp
--infodir=/opt/homebrew/Cellar/emacs/28.2/share/info/emacs
--prefix=/opt/homebrew/Cellar/emacs/28.2 --with-gnutls --without-x
--with-xml2 --without-dbus --with-modules --without-ns
--without-imagemagick --without-selinux'

Configured features:
ACL GMP GNUTLS JSON LIBXML2 MODULES NOTIFY KQUEUE PDUMPER THREADS ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: ELisp/d

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow regexp-opt sort mail-extr emacsbug message rmc puny dired
dired-loaddefs rfc822 mml mml-sec epa derived epg rfc6068 epg-config
gnus-util rmail rmail-loaddefs auth-source cl-seq eieio eieio-core
cl-macs eieio-loaddefs password-cache json map text-property-search
time-date subr-x mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils cl-print edebug backtrace help-mode
tool-bar find-func vc-mtn vc-hg vc-git diff-mode easy-mmode vc-bzr
vc-src vc-sccs vc-svn vc-cvs vc-rcs vc cl-loaddefs cl-lib vc-dispatcher
image project seq term/xterm xterm byte-opt gv bytecomp byte-compile
cconv iso-transl tooltip eldoc paren electric uniquify ediff-hook
vc-hooks lisp-float-type elisp-mode tabulated-list replace newcomment
text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow
isearch easymenu timer select mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite emoji-zwj charscript charprop case-table
epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice
button loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote threads kqueue multi-tty
make-network-process emacs)

Memory information:
((conses 16 72031 7674)
(symbols 48 8797 1)
(strings 32 26201 1172)
(string-bytes 1 817049)
(vectors 16 14915)
(vector-slots 8 168301 9701)
(floats 8 42 454)
(intervals 56 324 3)
(buffers 992 14))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58784; Package emacs. (Sat, 29 Oct 2022 00:50:02 GMT) Full text and rfc822 format available.

Message #8 received at 58784 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Sean Devlin <spd <at> toadstyle.org>, 58784 <at> debbugs.gnu.org
Subject: Re: bug#58784: 28.2; project-buffers incorrect under let-bound
 default-directory
Date: Sat, 29 Oct 2022 03:49:09 +0300
[Message part 1 (text/plain, inline)]
Hi!

On 26.10.2022 03:13, Sean Devlin wrote:
> The project.el function project-buffers can return incorrect results
> when invoked while a let-binding for default-directory is in
> effect. This is because project-buffers (both the default and vc-based
> implementations) does its work by inspecting the local value of
> default-directory in each buffer, and the let-binding temporarily
> affects this value.
> 
> To see this in action, start emacs with -Q and evaluate the following
> forms in order:
> 
> (require 'project)
> 
> (find-file-noselect "/tmp/tmpfile")
> (setq my-project '(transient . "/tmp/"))
> 
> ;; just the tmpfile
> (project-buffers my-project)
> 
> ;; both tmpfile and scratch
> (let ((default-directory "/tmp/"))
>    (project-buffers my-project))

Thanks for the report, I can see the problem.

> In the last form, project-buffers includes the current buffer (i.e. the
> scratch buffer in our example) with the results. (This is true even if
> the current buffer is visiting a file in some unrelated directory.)
> 
> This matters because the command project-switch-project let-binds
> default-directory before calling project-switch-commands. This means
> that if you set project-switch-commands to some function that calls
> project-buffers, you will get incorrect results.
> 
> For example, evaluate the following forms in order:
> 
> (defun my-list-project-buffers ()
>    "List the current project's buffers."
>    (interactive)
>    (let ((buffer-list (project-buffers (project-current t)))
> 	(buffer-name (project-prefixed-buffer-name "my-project-buffer-list")))
>      (with-current-buffer (get-buffer-create buffer-name)
>        (erase-buffer)
>        (save-excursion
> 	(dolist (buffer buffer-list)
> 	  (insert (buffer-name buffer))
> 	  (insert ?\n))))
>      (switch-to-buffer buffer-name)))
> 
> (setq project-switch-commands #'my-list-project-buffers)

Looks like a reimplementation of projectile-ibuffer, seems useful.

> ;; list tmpfile but also scratch
> (project-switch-project "/tmp/")

Not sure how to fix this, though. In bug#53626 we discussed a somewhat 
similar problem, and a let-binding seems impossible to "escape".

What else can we do? One option is to change the signature of every 
compatible command to take the project object as its first argument. 
Might have been more realistic when the package was first written, too 
much breakage now, probably.

Another would be to add a new var to help override the project choice 
without touch default-directory.

Something like the attached. Please try it out.
[project-current-directory-override.diff (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58784; Package emacs. (Mon, 31 Oct 2022 17:48:02 GMT) Full text and rfc822 format available.

Message #11 received at 58784 <at> debbugs.gnu.org (full text, mbox):

From: Sean Devlin <spd <at> toadstyle.org>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 58784 <at> debbugs.gnu.org
Subject: Re: bug#58784: 28.2; project-buffers incorrect under let-bound
 default-directory
Date: Mon, 31 Oct 2022 13:47:20 -0400
Hi Dmitry,

> On Oct 28, 2022, at 8:49 PM, Dmitry Gutov <dgutov <at> yandex.ru> wrote:
> 
> Hi!
> 
> On 26.10.2022 03:13, Sean Devlin wrote:
>> The project.el function project-buffers can return incorrect results
>> when invoked while a let-binding for default-directory is in
>> effect. This is because project-buffers (both the default and vc-based
>> implementations) does its work by inspecting the local value of
>> default-directory in each buffer, and the let-binding temporarily
>> affects this value.
>> To see this in action, start emacs with -Q and evaluate the following
>> forms in order:
>> (require 'project)
>> (find-file-noselect "/tmp/tmpfile")
>> (setq my-project '(transient . "/tmp/"))
>> ;; just the tmpfile
>> (project-buffers my-project)
>> ;; both tmpfile and scratch
>> (let ((default-directory "/tmp/"))
>>   (project-buffers my-project))
> 
> Thanks for the report, I can see the problem.
> 
>> In the last form, project-buffers includes the current buffer (i.e. the
>> scratch buffer in our example) with the results. (This is true even if
>> the current buffer is visiting a file in some unrelated directory.)
>> This matters because the command project-switch-project let-binds
>> default-directory before calling project-switch-commands. This means
>> that if you set project-switch-commands to some function that calls
>> project-buffers, you will get incorrect results.
>> For example, evaluate the following forms in order:
>> (defun my-list-project-buffers ()
>>   "List the current project's buffers."
>>   (interactive)
>>   (let ((buffer-list (project-buffers (project-current t)))
>> 	(buffer-name (project-prefixed-buffer-name "my-project-buffer-list")))
>>     (with-current-buffer (get-buffer-create buffer-name)
>>       (erase-buffer)
>>       (save-excursion
>> 	(dolist (buffer buffer-list)
>> 	  (insert (buffer-name buffer))
>> 	  (insert ?\n))))
>>     (switch-to-buffer buffer-name)))
>> (setq project-switch-commands #'my-list-project-buffers)
> 
> Looks like a reimplementation of projectile-ibuffer, seems useful.

Yeah, in my real configuration, I defined this as an ibuffer filter, but I thought a simpler example would be better for the bug report.

> 
>> ;; list tmpfile but also scratch
>> (project-switch-project "/tmp/")
> 
> Not sure how to fix this, though. In bug#53626 we discussed a somewhat similar problem, and a let-binding seems impossible to "escape".
> 
> What else can we do? One option is to change the signature of every compatible command to take the project object as its first argument. Might have been more realistic when the package was first written, too much breakage now, probably.
> 
> Another would be to add a new var to help override the project choice without touch default-directory.
> 
> Something like the attached. Please try it out.<project-current-directory-override.diff>

I agree, the fix is not obvious.

A workaround I used in my configuration is to add an advice to project-switch-project to wrap it in a with-temp-buffer form. This way, it’s only the default-directory of the temp buffer that gets corrupted. Not a very clean solution, but it seems to work. Unfortunately, you need to remember to do this in many places; for example, I had to do the same thing in my project-ibuffer command.

Your solution looks cleaner. I gave it a try (along with disabling my advice), and it seems to work pretty well. Thanks for the fix!

There might be some more places where it needs to be applied. For example, project-prefixed-buffer-name still inspects the default-directory. (Maybe project-prefixed-buffer-name should just call project-root or similar?)

I think there’s still some fragility in the project-buffers function, since any callers need to be careful not to bind default-directory. It might be useful to call this out in the doc string or in the manual.

Thanks for your help!



Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58784; Package emacs. (Tue, 01 Nov 2022 23:37:02 GMT) Full text and rfc822 format available.

Message #14 received at 58784 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Sean Devlin <spd <at> toadstyle.org>
Cc: 58784 <at> debbugs.gnu.org
Subject: Re: bug#58784: 28.2; project-buffers incorrect under let-bound
 default-directory
Date: Wed, 2 Nov 2022 01:35:58 +0200
Hi Sean,

On 31.10.2022 19:47, Sean Devlin wrote:

>>> In the last form, project-buffers includes the current buffer (i.e. the
>>> scratch buffer in our example) with the results. (This is true even if
>>> the current buffer is visiting a file in some unrelated directory.)
>>> This matters because the command project-switch-project let-binds
>>> default-directory before calling project-switch-commands. This means
>>> that if you set project-switch-commands to some function that calls
>>> project-buffers, you will get incorrect results.
>>> For example, evaluate the following forms in order:
>>> (defun my-list-project-buffers ()
>>>    "List the current project's buffers."
>>>    (interactive)
>>>    (let ((buffer-list (project-buffers (project-current t)))
>>> 	(buffer-name (project-prefixed-buffer-name "my-project-buffer-list")))
>>>      (with-current-buffer (get-buffer-create buffer-name)
>>>        (erase-buffer)
>>>        (save-excursion
>>> 	(dolist (buffer buffer-list)
>>> 	  (insert (buffer-name buffer))
>>> 	  (insert ?\n))))
>>>      (switch-to-buffer buffer-name)))
>>> (setq project-switch-commands #'my-list-project-buffers)
>>
>> Looks like a reimplementation of projectile-ibuffer, seems useful.
> 
> Yeah, in my real configuration, I defined this as an ibuffer filter, but I thought a simpler example would be better for the bug report.

Right, thanks.

>>> ;; list tmpfile but also scratch
>>> (project-switch-project "/tmp/")
>>
>> Not sure how to fix this, though. In bug#53626 we discussed a somewhat similar problem, and a let-binding seems impossible to "escape".
>>
>> What else can we do? One option is to change the signature of every compatible command to take the project object as its first argument. Might have been more realistic when the package was first written, too much breakage now, probably.
>>
>> Another would be to add a new var to help override the project choice without touch default-directory.
>>
>> Something like the attached. Please try it out.<project-current-directory-override.diff>
> 
> I agree, the fix is not obvious.
> 
> A workaround I used in my configuration is to add an advice to project-switch-project to wrap it in a with-temp-buffer form. This way, it’s only the default-directory of the temp buffer that gets corrupted. Not a very clean solution, but it seems to work. Unfortunately, you need to remember to do this in many places; for example, I had to do the same thing in my project-ibuffer command.
> 
> Your solution looks cleaner. I gave it a try (along with disabling my advice), and it seems to work pretty well. Thanks for the fix!

Actually I like your solution better. It might be less obvious when 
reading, but it's shorter and fully backward compatible.

So I just pushed that fix to master.

> There might be some more places where it needs to be applied. For example, project-prefixed-buffer-name still inspects the default-directory. (Maybe project-prefixed-buffer-name should just call project-root or similar?)

In both places where project-prefixed-buffer-name is currently invoked, 
default-directory is set a specific binding just before that. So I think 
it would have been fine even with the other fix.

Or on a higher level, it acts on the current buffer, so referencing 
default-directory seems okay.

> I think there’s still some fragility in the project-buffers function, since any callers need to be careful not to bind default-directory. It might be useful to call this out in the doc string or in the manual.

I suppose it could use improvement, but I'm not sure what phrasing would 
stop someone from making such a mistake. After all, I knew its 
implementation and made it anyway.

Perhaps the docstring should simply say that the buffers are matched on 
the basis of their default-directory value. In the default 
implementation, that is (custom backends could choose their own 
strategy). Would that help?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58784; Package emacs. (Wed, 02 Nov 2022 15:20:01 GMT) Full text and rfc822 format available.

Message #17 received at 58784 <at> debbugs.gnu.org (full text, mbox):

From: Sean Devlin <spd <at> toadstyle.org>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 58784 <at> debbugs.gnu.org
Subject: Re: bug#58784: 28.2; project-buffers incorrect under let-bound
 default-directory
Date: Wed, 2 Nov 2022 11:18:49 -0400
Hi Dmitry,

> On Nov 1, 2022, at 7:35 PM, Dmitry Gutov <dgutov <at> yandex.ru> wrote:
> 
> Hi Sean,
> 
> On 31.10.2022 19:47, Sean Devlin wrote:
> 
>>>> In the last form, project-buffers includes the current buffer (i.e. the
>>>> scratch buffer in our example) with the results. (This is true even if
>>>> the current buffer is visiting a file in some unrelated directory.)
>>>> This matters because the command project-switch-project let-binds
>>>> default-directory before calling project-switch-commands. This means
>>>> that if you set project-switch-commands to some function that calls
>>>> project-buffers, you will get incorrect results.
>>>> For example, evaluate the following forms in order:
>>>> (defun my-list-project-buffers ()
>>>>   "List the current project's buffers."
>>>>   (interactive)
>>>>   (let ((buffer-list (project-buffers (project-current t)))
>>>> 	(buffer-name (project-prefixed-buffer-name "my-project-buffer-list")))
>>>>     (with-current-buffer (get-buffer-create buffer-name)
>>>>       (erase-buffer)
>>>>       (save-excursion
>>>> 	(dolist (buffer buffer-list)
>>>> 	  (insert (buffer-name buffer))
>>>> 	  (insert ?\n))))
>>>>     (switch-to-buffer buffer-name)))
>>>> (setq project-switch-commands #'my-list-project-buffers)
>>> 
>>> Looks like a reimplementation of projectile-ibuffer, seems useful.
>> Yeah, in my real configuration, I defined this as an ibuffer filter, but I thought a simpler example would be better for the bug report.
> 
> Right, thanks.
> 
>>>> ;; list tmpfile but also scratch
>>>> (project-switch-project "/tmp/")
>>> 
>>> Not sure how to fix this, though. In bug#53626 we discussed a somewhat similar problem, and a let-binding seems impossible to "escape".
>>> 
>>> What else can we do? One option is to change the signature of every compatible command to take the project object as its first argument. Might have been more realistic when the package was first written, too much breakage now, probably.
>>> 
>>> Another would be to add a new var to help override the project choice without touch default-directory.
>>> 
>>> Something like the attached. Please try it out.<project-current-directory-override.diff>
>> I agree, the fix is not obvious.
>> A workaround I used in my configuration is to add an advice to project-switch-project to wrap it in a with-temp-buffer form. This way, it’s only the default-directory of the temp buffer that gets corrupted. Not a very clean solution, but it seems to work. Unfortunately, you need to remember to do this in many places; for example, I had to do the same thing in my project-ibuffer command.
>> Your solution looks cleaner. I gave it a try (along with disabling my advice), and it seems to work pretty well. Thanks for the fix!
> 
> Actually I like your solution better. It might be less obvious when reading, but it's shorter and fully backward compatible.
> 
> So I just pushed that fix to master.

Great, thanks!

> 
>> There might be some more places where it needs to be applied. For example, project-prefixed-buffer-name still inspects the default-directory. (Maybe project-prefixed-buffer-name should just call project-root or similar?)
> 
> In both places where project-prefixed-buffer-name is currently invoked, default-directory is set a specific binding just before that. So I think it would have been fine even with the other fix.
> 
> Or on a higher level, it acts on the current buffer, so referencing default-directory seems okay.

Sounds good.

> 
>> I think there’s still some fragility in the project-buffers function, since any callers need to be careful not to bind default-directory. It might be useful to call this out in the doc string or in the manual.
> 
> I suppose it could use improvement, but I'm not sure what phrasing would stop someone from making such a mistake. After all, I knew its implementation and made it anyway.
> 
> Perhaps the docstring should simply say that the buffers are matched on the basis of their default-directory value. In the default implementation, that is (custom backends could choose their own strategy). Would that help?

Yeah, I think a high-level description of the default strategy would be useful.

Thanks again for your help!





Reply sent to Dmitry Gutov <dgutov <at> yandex.ru>:
You have taken responsibility. (Fri, 04 Nov 2022 01:19:01 GMT) Full text and rfc822 format available.

Notification sent to Sean Devlin <spd <at> toadstyle.org>:
bug acknowledged by developer. (Fri, 04 Nov 2022 01:19:01 GMT) Full text and rfc822 format available.

Message #22 received at 58784-done <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Sean Devlin <spd <at> toadstyle.org>
Cc: 58784-done <at> debbugs.gnu.org
Subject: Re: bug#58784: 28.2; project-buffers incorrect under let-bound
 default-directory
Date: Fri, 4 Nov 2022 03:18:40 +0200
On 02.11.2022 17:18, Sean Devlin wrote:

>>> I think there’s still some fragility in the project-buffers function, since any callers need to be careful not to bind default-directory. It might be useful to call this out in the doc string or in the manual.
>>
>> I suppose it could use improvement, but I'm not sure what phrasing would stop someone from making such a mistake. After all, I knew its implementation and made it anyway.
>>
>> Perhaps the docstring should simply say that the buffers are matched on the basis of their default-directory value. In the default implementation, that is (custom backends could choose their own strategy). Would that help?
> 
> Yeah, I think a high-level description of the default strategy would be useful.
> 
> Thanks again for your help!

I've added some clarification in 7d47651d01.

Hopefully it makes things better, if not -- suggestions welcome.

I'm going to close this in the meantime.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58784; Package emacs. (Fri, 04 Nov 2022 16:40:02 GMT) Full text and rfc822 format available.

Message #25 received at 58784-done <at> debbugs.gnu.org (full text, mbox):

From: Sean Devlin <spd <at> toadstyle.org>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 58784-done <at> debbugs.gnu.org
Subject: Re: bug#58784: 28.2; project-buffers incorrect under let-bound
 default-directory
Date: Fri, 4 Nov 2022 12:39:18 -0400
Hi Dmitry,

> On Nov 3, 2022, at 9:18 PM, Dmitry Gutov <dgutov <at> yandex.ru> wrote:
> 
> On 02.11.2022 17:18, Sean Devlin wrote:
> 
>>>> I think there’s still some fragility in the project-buffers function, since any callers need to be careful not to bind default-directory. It might be useful to call this out in the doc string or in the manual.
>>> 
>>> I suppose it could use improvement, but I'm not sure what phrasing would stop someone from making such a mistake. After all, I knew its implementation and made it anyway.
>>> 
>>> Perhaps the docstring should simply say that the buffers are matched on the basis of their default-directory value. In the default implementation, that is (custom backends could choose their own strategy). Would that help?
>> Yeah, I think a high-level description of the default strategy would be useful.
>> Thanks again for your help!
> 
> I've added some clarification in 7d47651d01.
> 
> Hopefully it makes things better, if not -- suggestions welcome.
> 
> I'm going to close this in the meantime.

Thanks, and I saw the corresponding discussion on emacs-devel. Any version of the proposed changes looks good to me. Feel free to close, and thanks again for your help!



Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58784; Package emacs. (Mon, 21 Nov 2022 18:26:02 GMT) Full text and rfc822 format available.

Message #28 received at 58784 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: Sean Devlin <spd <at> toadstyle.org>, 58784 <at> debbugs.gnu.org
Subject: Re: bug#58784: 28.2; project-buffers incorrect under let-bound
 default-directory
Date: Mon, 21 Nov 2022 20:24:31 +0200
> So I just pushed that fix to master.

Unfortunately, this change broke 'C-x p p g':

  @@ -1667,9 +1667,10 @@ project-switch-project
  -    (let ((default-directory dir)
  -          (project-current-inhibit-prompt t))
  -      (call-interactively command))))
  +    (with-temp-buffer
  +      (let ((default-directory dir)
  +            (project-current-inhibit-prompt t))
  +        (call-interactively command)))))

Because 'C-x p p' switches to a temporary buffer, then
'g' calls 'project-find-regexp' and 'project--read-regexp'.
But (thing-at-point 'symbol t) can't get a symbol at point
in the empty temporary buffer.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58784; Package emacs. (Wed, 23 Nov 2022 03:49:02 GMT) Full text and rfc822 format available.

Message #31 received at 58784 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Juri Linkov <juri <at> linkov.net>
Cc: Sean Devlin <spd <at> toadstyle.org>, 58784 <at> debbugs.gnu.org
Subject: Re: bug#58784: 28.2; project-buffers incorrect under let-bound
 default-directory
Date: Wed, 23 Nov 2022 05:48:07 +0200
On 21/11/22 20:24, Juri Linkov wrote:
>> So I just pushed that fix to master.
> Unfortunately, this change broke 'C-x p p g':
> 
>    @@ -1667,9 +1667,10 @@ project-switch-project
>    -    (let ((default-directory dir)
>    -          (project-current-inhibit-prompt t))
>    -      (call-interactively command))))
>    +    (with-temp-buffer
>    +      (let ((default-directory dir)
>    +            (project-current-inhibit-prompt t))
>    +        (call-interactively command)))))
> 
> Because 'C-x p p' switches to a temporary buffer, then
> 'g' calls 'project-find-regexp' and 'project--read-regexp'.
> But (thing-at-point 'symbol t) can't get a symbol at point
> in the empty temporary buffer.

Damn it. :-)

Thanks for noticing. I'll need a little time to think about the options, 
but we'll probably go with the previous proposed fix.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58784; Package emacs. (Thu, 24 Nov 2022 02:38:01 GMT) Full text and rfc822 format available.

Message #34 received at 58784 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Juri Linkov <juri <at> linkov.net>
Cc: Sean Devlin <spd <at> toadstyle.org>, 58784 <at> debbugs.gnu.org
Subject: Re: bug#58784: 28.2; project-buffers incorrect under let-bound
 default-directory
Date: Thu, 24 Nov 2022 04:37:31 +0200
On 23/11/22 05:48, Dmitry Gutov wrote:
> we'll probably go with the previous proposed fix

And now done, master b37604c263.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 22 Dec 2022 12:24:12 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 132 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.