GNU bug report logs - #58447
[PATCH] In project-find-file, add absolute file name to history

Previous Next

Package: emacs;

Reported by: Augusto Stoffel <arstoffel <at> gmail.com>

Date: Tue, 11 Oct 2022 18:30:02 UTC

Severity: normal

Tags: patch

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 58447 in the body.
You can then email your comments to 58447 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#58447; Package emacs. (Tue, 11 Oct 2022 18:30:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Augusto Stoffel <arstoffel <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 11 Oct 2022 18:30:02 GMT) Full text and rfc822 format available.

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

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] In project-find-file, add absolute file name to history
Date: Tue, 11 Oct 2022 20:29:24 +0200
[Message part 1 (text/plain, inline)]
Tags: patch

`project-find-file' and related commands share their history with more
general commands like `find-file', so they should add the absolute file
name to history.  Currently, file names relative to the project root are
added.  The attached patch fixes this.

I've also replaced `concat' with `expand-file-name' at a certain point.
I see no reason why one shouldn't do that, but please have a look.

[0001-In-project-find-file-and-the-like-add-absolute-file-.patch (text/patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Tue, 11 Oct 2022 19:14:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file,
 add absolute file name to history
Date: Tue, 11 Oct 2022 22:13:59 +0300
> From: Augusto Stoffel <arstoffel <at> gmail.com>
> Date: Tue, 11 Oct 2022 20:29:24 +0200
> 
> `project-find-file' and related commands share their history with more
> general commands like `find-file', so they should add the absolute file
> name to history.  Currently, file names relative to the project root are
> added.  The attached patch fixes this.

Shouldn't project.el have its separate history of file names, perhaps
even a project-specific history?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Wed, 26 Oct 2022 09:05:01 GMT) Full text and rfc822 format available.

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

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 58447 <at> debbugs.gnu.org, Dmitry Gutov <dgutov <at> yandex.ru>
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Wed, 26 Oct 2022 11:04:44 +0200
I'm copying Dmitry.

On Tue, 11 Oct 2022 at 22:13, Eli Zaretskii wrote:

>> From: Augusto Stoffel <arstoffel <at> gmail.com>
>> Date: Tue, 11 Oct 2022 20:29:24 +0200
>> 
>> `project-find-file' and related commands share their history with more
>> general commands like `find-file', so they should add the absolute file
>> name to history.  Currently, file names relative to the project root are
>> added.  The attached patch fixes this.
>
> Shouldn't project.el have its separate history of file names,

I'm not sure that's useful, but then the history items should be
absolute file names anyway.

> perhaps even a project-specific history?

This might make sense.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Thu, 27 Oct 2022 08:45:01 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Augusto Stoffel <arstoffel <at> gmail.com>, Eli Zaretskii <eliz <at> gnu.org>
Cc: 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Thu, 27 Oct 2022 11:44:09 +0300
On 26.10.2022 12:04, Augusto Stoffel wrote:
> I'm copying Dmitry.

Hi!

> On Tue, 11 Oct 2022 at 22:13, Eli Zaretskii wrote:
> 
>>> From: Augusto Stoffel<arstoffel <at> gmail.com>
>>> Date: Tue, 11 Oct 2022 20:29:24 +0200
>>>
>>> `project-find-file' and related commands share their history with more
>>> general commands like `find-file', so they should add the absolute file
>>> name to history.  Currently, file names relative to the project root are
>>> added.  The attached patch fixes this.
>> Shouldn't project.el have its separate history of file names,
> I'm not sure that's useful, but then the history items should be
> absolute file names anyway.
> 
>> perhaps even a project-specific history?
> This might make sense.

I like both of these ideas, except I'm not sure how to implement the 
project-specific part better.

I suppose we won't be passing the history var to completing-read anymore?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Thu, 27 Oct 2022 13:17:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: arstoffel <at> gmail.com, 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Thu, 27 Oct 2022 16:15:53 +0300
> Date: Thu, 27 Oct 2022 11:44:09 +0300
> Cc: 58447 <at> debbugs.gnu.org
> From: Dmitry Gutov <dgutov <at> yandex.ru>
> 
> On 26.10.2022 12:04, Augusto Stoffel wrote:
> > I'm copying Dmitry.
> 
> Hi!
> 
> > On Tue, 11 Oct 2022 at 22:13, Eli Zaretskii wrote:
> > 
> >>> From: Augusto Stoffel<arstoffel <at> gmail.com>
> >>> Date: Tue, 11 Oct 2022 20:29:24 +0200
> >>>
> >>> `project-find-file' and related commands share their history with more
> >>> general commands like `find-file', so they should add the absolute file
> >>> name to history.  Currently, file names relative to the project root are
> >>> added.  The attached patch fixes this.
> >> Shouldn't project.el have its separate history of file names,
> > I'm not sure that's useful, but then the history items should be
> > absolute file names anyway.
> > 
> >> perhaps even a project-specific history?
> > This might make sense.
> 
> I like both of these ideas, except I'm not sure how to implement the 
> project-specific part better.
> 
> I suppose we won't be passing the history var to completing-read anymore?

I thought about a project-specific history variable.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Thu, 27 Oct 2022 14:22:01 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: arstoffel <at> gmail.com, 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Thu, 27 Oct 2022 17:21:24 +0300
On 27.10.2022 16:15, Eli Zaretskii wrote:
>> Date: Thu, 27 Oct 2022 11:44:09 +0300
>> Cc:58447 <at> debbugs.gnu.org
>> From: Dmitry Gutov<dgutov <at> yandex.ru>
>>
>> On 26.10.2022 12:04, Augusto Stoffel wrote:
>>> I'm copying Dmitry.
>> Hi!
>>
>>> On Tue, 11 Oct 2022 at 22:13, Eli Zaretskii wrote:
>>>
>>>>> From: Augusto Stoffel<arstoffel <at> gmail.com>
>>>>> Date: Tue, 11 Oct 2022 20:29:24 +0200
>>>>>
>>>>> `project-find-file' and related commands share their history with more
>>>>> general commands like `find-file', so they should add the absolute file
>>>>> name to history.  Currently, file names relative to the project root are
>>>>> added.  The attached patch fixes this.
>>>> Shouldn't project.el have its separate history of file names,
>>> I'm not sure that's useful, but then the history items should be
>>> absolute file names anyway.
>>>
>>>> perhaps even a project-specific history?
>>> This might make sense.
>> I like both of these ideas, except I'm not sure how to implement the
>> project-specific part better.
>>
>> I suppose we won't be passing the history var to completing-read anymore?
> I thought about a project-specific history variable.

...one global variable per project?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Thu, 27 Oct 2022 14:27:01 GMT) Full text and rfc822 format available.

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

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Thu, 27 Oct 2022 16:26:05 +0200
On Thu, 27 Oct 2022 at 17:21, Dmitry Gutov wrote:

> On 27.10.2022 16:15, Eli Zaretskii wrote:
>>> Date: Thu, 27 Oct 2022 11:44:09 +0300
>>> Cc:58447 <at> debbugs.gnu.org
>>> From: Dmitry Gutov<dgutov <at> yandex.ru>
>>>
>>> On 26.10.2022 12:04, Augusto Stoffel wrote:
>>>> I'm copying Dmitry.
>>> Hi!
>>>
>>>> On Tue, 11 Oct 2022 at 22:13, Eli Zaretskii wrote:
>>>>
>>>>>> From: Augusto Stoffel<arstoffel <at> gmail.com>
>>>>>> Date: Tue, 11 Oct 2022 20:29:24 +0200
>>>>>>
>>>>>> `project-find-file' and related commands share their history with more
>>>>>> general commands like `find-file', so they should add the absolute file
>>>>>> name to history.  Currently, file names relative to the project root are
>>>>>> added.  The attached patch fixes this.
>>>>> Shouldn't project.el have its separate history of file names,
>>>> I'm not sure that's useful, but then the history items should be
>>>> absolute file names anyway.
>>>>
>>>>> perhaps even a project-specific history?
>>>> This might make sense.
>>> I like both of these ideas, except I'm not sure how to implement the
>>> project-specific part better.
>>>
>>> I suppose we won't be passing the history var to completing-read anymore?
>> I thought about a project-specific history variable.
>
> ...one global variable per project?

One thing to consider here is compatibility with savehist-mode and the
like.  I guess the only simple way to achieve this is with one global
variable per project.  And then there would be the issue of when to
garbage-collect the saved save pertaining to old projects.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Thu, 27 Oct 2022 15:37:02 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Thu, 27 Oct 2022 18:36:13 +0300
On 27.10.2022 17:26, Augusto Stoffel wrote:
> One thing to consider here is compatibility with savehist-mode and the
> like.  I guess the only simple way to achieve this is with one global
> variable per project.

I suppose interning a symbol with the project root directory in its name 
could work.

Passing it to completing-read will unavoidably result in relative names 
still, though. But it won't be so much of a problem anymore.

> And then there would be the issue of when to
> garbage-collect the saved save pertaining to old projects.

Inside project--remove-from-project-list? Either one specific project, 
or doing a full scan of obarray.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Thu, 27 Oct 2022 15:53:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: arstoffel <at> gmail.com, 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Thu, 27 Oct 2022 18:52:21 +0300
> Date: Thu, 27 Oct 2022 17:21:24 +0300
> Cc: arstoffel <at> gmail.com, 58447 <at> debbugs.gnu.org
> From: Dmitry Gutov <dgutov <at> yandex.ru>
> 
> >> I like both of these ideas, except I'm not sure how to implement the
> >> project-specific part better.
> >>
> >> I suppose we won't be passing the history var to completing-read anymore?
> > I thought about a project-specific history variable.
> 
> ...one global variable per project?

Yes, I think so.  Are there any downsides that I overlooked?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Thu, 27 Oct 2022 15:57:02 GMT) Full text and rfc822 format available.

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

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Thu, 27 Oct 2022 17:56:39 +0200
On Thu, 27 Oct 2022 at 18:36, Dmitry Gutov wrote:

> On 27.10.2022 17:26, Augusto Stoffel wrote:
>> One thing to consider here is compatibility with savehist-mode and the
>> like.  I guess the only simple way to achieve this is with one global
>> variable per project.
>
> I suppose interning a symbol with the project root directory in its
> name could work.

The project root directory or the project name?  I'd say the latter.

If you have two copies of the same project in two different places
(which I often have -- a local copy and one in a remote compute
machine), then the shell and compilation buffers are shared.  One can
argue whether this is good or bad (I find it okay, with some caveats),
but for the sake of consistency the history variable should also be
shared among copies of the same project.

> Passing it to completing-read will unavoidably result in relative
> names still, though. But it won't be so much of a problem anymore.

If we settle for one history variable per project, then I'd say yes, the
entries should be relative file names.

>> And then there would be the issue of when to
>> garbage-collect the saved save pertaining to old projects.
>
> Inside project--remove-from-project-list? Either one specific project,
> or doing a full scan of obarray.

Okay, if "garbage collection" of projects is already a thing, then we
just have to extend it to contemplate the history variable.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Thu, 27 Oct 2022 16:08:01 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Thu, 27 Oct 2022 19:07:35 +0300
On 27.10.2022 18:56, Augusto Stoffel wrote:
> On Thu, 27 Oct 2022 at 18:36, Dmitry Gutov wrote:
> 
>> On 27.10.2022 17:26, Augusto Stoffel wrote:
>>> One thing to consider here is compatibility with savehist-mode and the
>>> like.  I guess the only simple way to achieve this is with one global
>>> variable per project.
>> I suppose interning a symbol with the project root directory in its
>> name could work.
> The project root directory or the project name?  I'd say the latter.

We don't have a "project name" generic yet. There is a bug open.

And even so, unrelated projects could declare equal names, couldn't they?

> If you have two copies of the same project in two different places
> (which I often have -- a local copy and one in a remote compute
> machine), then the shell and compilation buffers are shared.  One can
> argue whether this is good or bad (I find it okay, with some caveats),
> but for the sake of consistency the history variable should also be
> shared among copies of the same project.

I imagined the project names would be used in the project selector 
instead of their root directories, not in addition to them. So they'd 
have to be unique even across "copied projects".

But you can bring up that idea in bug#48747.

>> Passing it to completing-read will unavoidably result in relative
>> names still, though. But it won't be so much of a problem anymore.
> If we settle for one history variable per project, then I'd say yes, the
> entries should be relative file names.

Ok.

>>> And then there would be the issue of when to
>>> garbage-collect the saved save pertaining to old projects.
>> Inside project--remove-from-project-list? Either one specific project,
>> or doing a full scan of obarray.
> Okay, if "garbage collection" of projects is already a thing, then we
> just have to extend it to contemplate the history variable.

There is no "garbage collection" point exactly, but we could pivot to 
making one.

The main reason I didn't do that is scanning the full project list with 
file-readable-p check will likely become slow quickly enough, especially 
in the presence of remote projects.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Thu, 27 Oct 2022 16:11:02 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: arstoffel <at> gmail.com, 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Thu, 27 Oct 2022 19:10:38 +0300
On 27.10.2022 18:52, Eli Zaretskii wrote:
>> Date: Thu, 27 Oct 2022 17:21:24 +0300
>> Cc:arstoffel <at> gmail.com,58447 <at> debbugs.gnu.org
>> From: Dmitry Gutov<dgutov <at> yandex.ru>
>>
>>>> I like both of these ideas, except I'm not sure how to implement the
>>>> project-specific part better.
>>>>
>>>> I suppose we won't be passing the history var to completing-read anymore?
>>> I thought about a project-specific history variable.
>> ...one global variable per project?
> Yes, I think so.  Are there any downsides that I overlooked?

The idea of having a multitude of similar variables gave me a pause. But 
it's not a deal-breaker, I suppose.

Also a couple of questions we're talking about in the other branch.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Thu, 27 Oct 2022 16:38:02 GMT) Full text and rfc822 format available.

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

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Thu, 27 Oct 2022 18:37:39 +0200
On Thu, 27 Oct 2022 at 19:10, Dmitry Gutov wrote:

> The idea of having a multitude of similar variables gave me a
> pause. But it's not a deal-breaker, I suppose.
>
> Also a couple of questions we're talking about in the other branch.

I think the idea of per-project histories is an interesting feature that
requires some careful design, but note that there is a bug in
project-find-file that should ideally be fixed for Emacs 29 (namely, it
pollutes the find-file history by adding non-absolute file names to it).

The patch in my original message fixes this and shouldn't complicate a
future implementation of the per-project histories.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Thu, 27 Oct 2022 16:49:02 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Thu, 27 Oct 2022 19:48:10 +0300
On 27.10.2022 19:37, Augusto Stoffel wrote:
> The patch in my original message fixes this and shouldn't complicate a
> future implementation of the per-project histories.

OK. Are you sure that it doesn't add the relative name to the history still?

AFAIU as long as hist is passed to project--completing-read-strict,  the 
completing-read call in there will alter the history first.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Thu, 27 Oct 2022 16:54:02 GMT) Full text and rfc822 format available.

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

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Thu, 27 Oct 2022 18:53:35 +0200
On Thu, 27 Oct 2022 at 19:48, Dmitry Gutov wrote:

> On 27.10.2022 19:37, Augusto Stoffel wrote:
>> The patch in my original message fixes this and shouldn't complicate a
>> future implementation of the per-project histories.
>
> OK. Are you sure that it doesn't add the relative name to the history still?
>
> AFAIU as long as hist is passed to project--completing-read-strict,
> the completing-read call in there will alter the history first.

Note that history-add-new-input is bound to nil at the appropriate
place in the patch.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Thu, 27 Oct 2022 17:35:02 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Thu, 27 Oct 2022 20:34:18 +0300
On 27.10.2022 19:53, Augusto Stoffel wrote:
> On Thu, 27 Oct 2022 at 19:48, Dmitry Gutov wrote:
> 
>> On 27.10.2022 19:37, Augusto Stoffel wrote:
>>> The patch in my original message fixes this and shouldn't complicate a
>>> future implementation of the per-project histories.
>> OK. Are you sure that it doesn't add the relative name to the history still?
>>
>> AFAIU as long as hist is passed to project--completing-read-strict,
>> the completing-read call in there will alter the history first.
> Note that history-add-new-input is bound to nil at the appropriate
> place in the patch.

Ah, ok.

But how is completing-read using the history var? Only reading past 
inputs? Can it handle the absolute values there?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Thu, 27 Oct 2022 17:49:01 GMT) Full text and rfc822 format available.

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

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Thu, 27 Oct 2022 19:48:42 +0200
On Thu, 27 Oct 2022 at 20:34, Dmitry Gutov wrote:

> On 27.10.2022 19:53, Augusto Stoffel wrote:
>> On Thu, 27 Oct 2022 at 19:48, Dmitry Gutov wrote:
>> 
>>> On 27.10.2022 19:37, Augusto Stoffel wrote:
>>>> The patch in my original message fixes this and shouldn't complicate a
>>>> future implementation of the per-project histories.
>>> OK. Are you sure that it doesn't add the relative name to the history still?
>>>
>>> AFAIU as long as hist is passed to project--completing-read-strict,
>>> the completing-read call in there will alter the history first.
>> Note that history-add-new-input is bound to nil at the appropriate
>> place in the patch.
>
> Ah, ok.
>
> But how is completing-read using the history var? Only reading past
> inputs?

Yes, completing-read will make past inputs available for selection but
not updated the history variable.  Then, a couple lines later in the
patch, we update the history manually:

    (when (and hist history-add-new-input)
      (add-to-history hist absname))

> Can it handle the absolute values there?

The completing read reads a file name, the relname; if it's relative,
then it's expanded to an absolute name (the absname).  If for whatever
reason the relname was already absolute, then absname will be equal to
relname (what else could you do, right?)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Thu, 27 Oct 2022 18:06:02 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Thu, 27 Oct 2022 21:05:07 +0300
On 27.10.2022 20:48, Augusto Stoffel wrote:
>> Can it handle the absolute values there?
> The completing read reads a file name, the relname; if it's relative,
> then it's expanded to an absolute name (the absname).  If for whatever
> reason the relname was already absolute, then absname will be equal to
> relname (what else could you do, right?)

The completion table won't match absolute names. But okay, require-match 
is nil there, so any arbitrary input will be accepted.

But what if that absolute name comes from a different project?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Thu, 27 Oct 2022 18:13:02 GMT) Full text and rfc822 format available.

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

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Thu, 27 Oct 2022 20:12:45 +0200
On Thu, 27 Oct 2022 at 21:05, Dmitry Gutov wrote:

> On 27.10.2022 20:48, Augusto Stoffel wrote:
>>> Can it handle the absolute values there?
>> The completing read reads a file name, the relname; if it's relative,
>> then it's expanded to an absolute name (the absname).  If for whatever
>> reason the relname was already absolute, then absname will be equal to
>> relname (what else could you do, right?)
>
> The completion table won't match absolute names. But okay,
> require-match is nil there, so any arbitrary input will be accepted.

Right.

> But what if that absolute name comes from a different project?

In my patch it will just find that file.  Alternatively we could throw
an error, but I don't see a point in doing that.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Thu, 27 Oct 2022 19:46:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 58447 <at> debbugs.gnu.org,
 Dmitry Gutov <dgutov <at> yandex.ru>
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Thu, 27 Oct 2022 22:41:56 +0300
> I think the idea of per-project histories is an interesting feature that
> requires some careful design, but note that there is a bug in
> project-find-file that should ideally be fixed for Emacs 29 (namely, it
> pollutes the find-file history by adding non-absolute file names to it).
>
> The patch in my original message fixes this and shouldn't complicate a
> future implementation of the per-project histories.

Would be nice to fix this.  The problem that I have is that when a file
visited by 'C-x p f non-absolute/filename' needs to be revisited later,
then the quickest way is with 'C-x C-f M-p', but currently it fails
with non-absolute file names.

But please note that the same problem exists in both ways:
when trying to revisit an absolute file names previously visited
by 'C-x C-f', then 'C-x p f' fails on absolute file names.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Thu, 27 Oct 2022 19:52:02 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Thu, 27 Oct 2022 22:51:45 +0300
On 27.10.2022 21:12, Augusto Stoffel wrote:
>> But what if that absolute name comes from a different project?
> In my patch it will just find that file.  Alternatively we could throw
> an error, but I don't see a point in doing that.

OK, if that is the behavior you want, I don't mind.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Fri, 28 Oct 2022 18:13:01 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Juri Linkov <juri <at> linkov.net>, Augusto Stoffel <arstoffel <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Fri, 28 Oct 2022 21:11:58 +0300
Hi Juri,

On 27.10.2022 22:41, Juri Linkov wrote:
> But please note that the same problem exists in both ways:
> when trying to revisit an absolute file names previously visited
> by 'C-x C-f', then 'C-x p f' fails on absolute file names.

Does Augusto's patch from the first message make things better for you?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Sat, 29 Oct 2022 17:57:01 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Augusto Stoffel <arstoffel <at> gmail.com>,
 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Sat, 29 Oct 2022 20:45:27 +0300
>> But please note that the same problem exists in both ways:
>> when trying to revisit an absolute file names previously visited
>> by 'C-x C-f', then 'C-x p f' fails on absolute file names.
>
> Does Augusto's patch from the first message make things better for you?

Augusto's patch makes things better, but fails to read absolute file names.
To fix this, project--read-file-cpd-relative also need to accept absolute
file names.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Sun, 30 Oct 2022 19:43:01 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Juri Linkov <juri <at> linkov.net>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Augusto Stoffel <arstoffel <at> gmail.com>,
 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Sun, 30 Oct 2022 21:42:46 +0200
On 29.10.2022 20:45, Juri Linkov wrote:
>>> But please note that the same problem exists in both ways:
>>> when trying to revisit an absolute file names previously visited
>>> by 'C-x C-f', then 'C-x p f' fails on absolute file names.
>> Does Augusto's patch from the first message make things better for you?
> Augusto's patch makes things better, but fails to read absolute file names.
> To fix this, project--read-file-cpd-relative also need to accept absolute
> file names.

Augusto, what do you say to that?




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

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

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: Dmitry Gutov <dgutov <at> yandex.ru>, Juri Linkov <juri <at> linkov.net>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Mon, 31 Oct 2022 09:06:50 +0100
On Sun, 30 Oct 2022 at 21:42, Dmitry Gutov wrote:

> On 29.10.2022 20:45, Juri Linkov wrote:
>>>> But please note that the same problem exists in both ways:
>>>> when trying to revisit an absolute file names previously visited
>>>> by 'C-x C-f', then 'C-x p f' fails on absolute file names.
>>> Does Augusto's patch from the first message make things better for you?
>> Augusto's patch makes things better, but fails to read absolute file names.
>> To fix this, project--read-file-cpd-relative also need to accept absolute
>> file names.
>
> Augusto, what do you say to that?

I'm not quite sure what Juri meant here.  If from some project I do

  C-x p f /tmp RET RET

then Emacs opens the /tmp dired buffer (RET twice because REQUIRE-MATCH
is 'confirm), as I think it should.




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

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

From: Juri Linkov <juri <at> linkov.net>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 58447 <at> debbugs.gnu.org,
 Dmitry Gutov <dgutov <at> yandex.ru>
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Tue, 01 Nov 2022 19:30:54 +0200
> I'm not quite sure what Juri meant here.  If from some project I do
>
>   C-x p f /tmp RET RET
>
> then Emacs opens the /tmp dired buffer (RET twice because REQUIRE-MATCH
> is 'confirm), as I think it should.

Actually, that [Confirm] part is not quite a hassle, so your patch
already handles that in both ways, thanks for this.




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

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Juri Linkov <juri <at> linkov.net>, Augusto Stoffel <arstoffel <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Wed, 2 Nov 2022 00:14:18 +0200
On 01.11.2022 19:30, Juri Linkov wrote:
>> I'm not quite sure what Juri meant here.  If from some project I do
>>
>>    C-x p f /tmp RET RET
>>
>> then Emacs opens the /tmp dired buffer (RET twice because REQUIRE-MATCH
>> is 'confirm), as I think it should.
> Actually, that [Confirm] part is not quite a hassle, so your patch
> already handles that in both ways, thanks for this.

Thanks for verifying.

LGTM then.




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

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

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 58447 <at> debbugs.gnu.org,
 Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Fri, 18 Nov 2022 11:28:07 -0500
[Message part 1 (text/plain, inline)]
On Wed,  2 Nov 2022 at 00:14, Dmitry Gutov wrote:

> On 01.11.2022 19:30, Juri Linkov wrote:
>>> I'm not quite sure what Juri meant here.  If from some project I do
>>>
>>>    C-x p f /tmp RET RET
>>>
>>> then Emacs opens the /tmp dired buffer (RET twice because REQUIRE-MATCH
>>> is 'confirm), as I think it should.
>> Actually, that [Confirm] part is not quite a hassle, so your patch
>> already handles that in both ways, thanks for this.
>
> Thanks for verifying.
>
> LGTM then.

FTR, someone would have to install the patch on my behalf.  I've
attached it again for your convenience.

[0001-In-project-find-file-and-the-like-add-absolute-file-.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Fri, 25 Nov 2022 13:39:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: dgutov <at> yandex.ru, Augusto Stoffel <arstoffel <at> gmail.com>
Cc: 58447 <at> debbugs.gnu.org, juri <at> linkov.net
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Fri, 25 Nov 2022 15:39:02 +0200
> From: Augusto Stoffel <arstoffel <at> gmail.com>
> Cc: Juri Linkov <juri <at> linkov.net>,  Eli Zaretskii <eliz <at> gnu.org>,
>   58447 <at> debbugs.gnu.org
> Date: Fri, 18 Nov 2022 11:28:07 -0500
> 
> On Wed,  2 Nov 2022 at 00:14, Dmitry Gutov wrote:
> 
> > On 01.11.2022 19:30, Juri Linkov wrote:
> >>> I'm not quite sure what Juri meant here.  If from some project I do
> >>>
> >>>    C-x p f /tmp RET RET
> >>>
> >>> then Emacs opens the /tmp dired buffer (RET twice because REQUIRE-MATCH
> >>> is 'confirm), as I think it should.
> >> Actually, that [Confirm] part is not quite a hassle, so your patch
> >> already handles that in both ways, thanks for this.
> >
> > Thanks for verifying.
> >
> > LGTM then.
> 
> FTR, someone would have to install the patch on my behalf.  I've
> attached it again for your convenience.

Thanks.  Dmitry, should this go in?




Reply sent to Dmitry Gutov <dgutov <at> yandex.ru>:
You have taken responsibility. (Sat, 26 Nov 2022 02:30:02 GMT) Full text and rfc822 format available.

Notification sent to Augusto Stoffel <arstoffel <at> gmail.com>:
bug acknowledged by developer. (Sat, 26 Nov 2022 02:30:02 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Juri Linkov <juri <at> linkov.net>,
 58447-done <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Sat, 26 Nov 2022 04:28:50 +0200
On 18/11/22 18:28, Augusto Stoffel wrote:
> On Wed,  2 Nov 2022 at 00:14, Dmitry Gutov wrote:
> 
>> On 01.11.2022 19:30, Juri Linkov wrote:
>>>> I'm not quite sure what Juri meant here.  If from some project I do
>>>>
>>>>     C-x p f /tmp RET RET
>>>>
>>>> then Emacs opens the /tmp dired buffer (RET twice because REQUIRE-MATCH
>>>> is 'confirm), as I think it should.
>>> Actually, that [Confirm] part is not quite a hassle, so your patch
>>> already handles that in both ways, thanks for this.
>> Thanks for verifying.
>>
>> LGTM then.
> FTR, someone would have to install the patch on my behalf.  I've
> attached it again for your convenience.

Sorry, I figured you had commit access.

Now pushed, thanks.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Mon, 28 Nov 2022 22:59:02 GMT) Full text and rfc822 format available.

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

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: 58447 <at> debbugs.gnu.org
Cc: dgutov <at> yandex.ru
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Mon, 28 Nov 2022 23:58:32 +0100
[Message part 1 (text/plain, inline)]
On Sat, 26 Nov 2022 at 04:28, Dmitry Gutov wrote:

> Sorry, I figured you had commit access.
>
> Now pushed, thanks.

It has been brought to my attention that I should have used
`abbreviate-file-name' for file name history items.  Unfortunately we
need to push a small fix.  Hopefully this can go in Emacs 29.

[0001-In-project-find-file-add-abbreviated-file-names-to-h.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Tue, 29 Nov 2022 16:30:02 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Augusto Stoffel <arstoffel <at> gmail.com>, 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Tue, 29 Nov 2022 18:29:13 +0200
On 29/11/2022 00:58, Augusto Stoffel wrote:
> On Sat, 26 Nov 2022 at 04:28, Dmitry Gutov wrote:
> 
>> Sorry, I figured you had commit access.
>>
>> Now pushed, thanks.
> It has been brought to my attention that I should have used
> `abbreviate-file-name' for file name history items.  Unfortunately we
> need to push a small fix.  Hopefully this can go in Emacs 29.

Looks indeed like a bugfix to me.

Pushed to emacs-29, thanks.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Fri, 09 Dec 2022 07:44:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 58447 <at> debbugs.gnu.org,
 Dmitry Gutov <dgutov <at> yandex.ru>
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Fri, 09 Dec 2022 09:38:34 +0200
>> I'm not quite sure what Juri meant here.  If from some project I do
>>
>>   C-x p f /tmp RET RET
>>
>> then Emacs opens the /tmp dired buffer (RET twice because REQUIRE-MATCH
>> is 'confirm), as I think it should.
>
> Actually, that [Confirm] part is not quite a hassle, so your patch
> already handles that in both ways, thanks for this.

After stumbling on this confirmation snag every time while using 'C-x p f M-p',
I have to admit this is still a hassle that needs to be avoided in some way.

One solution would be to write a confirmation function instead of using
the symbol 'confirm' for completing-read in project--completing-read-strict.
Such a function could check if the filename is absolute and not require
confirmation in this case.

Another solution would be to add absolute filenames to the history
'file-name-history' used by 'C-x C-f'.  Then add relative filenames
to another history e.g. 'project-file-name-history' that will be used
only by 'C-x p f'.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Fri, 09 Dec 2022 13:01:02 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Juri Linkov <juri <at> linkov.net>, Augusto Stoffel <arstoffel <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Fri, 9 Dec 2022 15:00:36 +0200
On 09/12/2022 09:38, Juri Linkov wrote:
> One solution would be to write a confirmation function instead of using
> the symbol 'confirm' for completing-read in project--completing-read-strict.
> Such a function could check if the filename is absolute

And exists, I suppose?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Sat, 10 Dec 2022 17:48:01 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Augusto Stoffel <arstoffel <at> gmail.com>,
 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Sat, 10 Dec 2022 19:27:48 +0200
>> One solution would be to write a confirmation function instead of using
>> the symbol 'confirm' for completing-read in project--completing-read-strict.
>> Such a function could check if the filename is absolute
>
> And exists, I suppose?

I'd prefer to have separate histories: with absolute filenames for C-x C-f,
and project-relative filenames for C-x p f.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Sat, 10 Dec 2022 19:51:01 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Juri Linkov <juri <at> linkov.net>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Augusto Stoffel <arstoffel <at> gmail.com>,
 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Sat, 10 Dec 2022 21:50:41 +0200
On 10/12/2022 19:27, Juri Linkov wrote:
>>> One solution would be to write a confirmation function instead of using
>>> the symbol 'confirm' for completing-read in project--completing-read-strict.
>>> Such a function could check if the filename is absolute
>>
>> And exists, I suppose?
> 
> I'd prefer to have separate histories: with absolute filenames for C-x C-f,
> and project-relative filenames for C-x p f.

Yeah, ok.

I think we just postponed this improvement because we might not manage 
it in time for the 29's release.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Sun, 11 Dec 2022 17:59:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Augusto Stoffel <arstoffel <at> gmail.com>,
 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Sun, 11 Dec 2022 19:57:59 +0200
>>>> One solution would be to write a confirmation function instead of using
>>>> the symbol 'confirm' for completing-read in project--completing-read-strict.
>>>> Such a function could check if the filename is absolute
>>>
>>> And exists, I suppose?
>> I'd prefer to have separate histories: with absolute filenames for C-x
>> C-f,
>> and project-relative filenames for C-x p f.
>
> Yeah, ok.
>
> I think we just postponed this improvement because we might not manage it
> in time for the 29's release.

Unfortunately, this makes the emacs-29 release unusable.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Sun, 11 Dec 2022 18:15:01 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Juri Linkov <juri <at> linkov.net>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Augusto Stoffel <arstoffel <at> gmail.com>,
 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Sun, 11 Dec 2022 20:14:22 +0200
On 11/12/2022 19:57, Juri Linkov wrote:
>>>>> One solution would be to write a confirmation function instead of using
>>>>> the symbol 'confirm' for completing-read in project--completing-read-strict.
>>>>> Such a function could check if the filename is absolute
>>>> And exists, I suppose?
>>> I'd prefer to have separate histories: with absolute filenames for C-x
>>> C-f,
>>> and project-relative filenames for C-x p f.
>> Yeah, ok.
>>
>> I think we just postponed this improvement because we might not manage it
>> in time for the 29's release.
> Unfortunately, this makes the emacs-29 release unusable.

Would you say the new behavior is worse than what we had before?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Mon, 12 Dec 2022 17:45:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Augusto Stoffel <arstoffel <at> gmail.com>,
 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Mon, 12 Dec 2022 19:41:52 +0200
>>>>>> One solution would be to write a confirmation function instead of using
>>>>>> the symbol 'confirm' for completing-read in project--completing-read-strict.
>>>>>> Such a function could check if the filename is absolute
>>>>> And exists, I suppose?
>>>> I'd prefer to have separate histories: with absolute filenames for C-x
>>>> C-f,
>>>> and project-relative filenames for C-x p f.
>>> Yeah, ok.
>>>
>>> I think we just postponed this improvement because we might not manage it
>>> in time for the 29's release.
>> Unfortunately, this makes the emacs-29 release unusable.
>
> Would you say the new behavior is worse than what we had before?

Unfortunately, yes.  It turned out that it interferes too much
in normal workflows of using 'C-x p f'.  I suggest to keep
the history of 'C-x p f' with relative filenames intact,
and add absolute filenames to 'file-name-history' that already
contains absolute filenames.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Mon, 12 Dec 2022 18:50:01 GMT) Full text and rfc822 format available.

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

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 58447 <at> debbugs.gnu.org,
 Dmitry Gutov <dgutov <at> yandex.ru>
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Mon, 12 Dec 2022 19:49:16 +0100
>>> Unfortunately, this makes the emacs-29 release unusable.
>>
>> Would you say the new behavior is worse than what we had before?
>
> Unfortunately, yes.  It turned out that it interferes too much
> in normal workflows of using 'C-x p f'.  I suggest to keep
> the history of 'C-x p f' with relative filenames intact,
> and add absolute filenames to 'file-name-history' that already
> contains absolute filenames.

Until now, `C-x p f' and `C-x C-f' have always shared the same history
variable, `file-name-history'.  Reverting this change to go back to the
even more broken (IMO) behavior of adding relative file names to the
history of `C-x C-f' et al.

How about computing the history of `C-x p f' dynamically by filtering
the elements of `file-name-history' which belong to the current project?
This is simpler than the other viable solution, to introduce
project-dependent histories.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Tue, 13 Dec 2022 17:30:03 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 58447 <at> debbugs.gnu.org,
 Dmitry Gutov <dgutov <at> yandex.ru>
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Tue, 13 Dec 2022 19:28:10 +0200
>>> Would you say the new behavior is worse than what we had before?
>>
>> Unfortunately, yes.  It turned out that it interferes too much
>> in normal workflows of using 'C-x p f'.  I suggest to keep
>> the history of 'C-x p f' with relative filenames intact,
>> and add absolute filenames to 'file-name-history' that already
>> contains absolute filenames.
>
> Until now, `C-x p f' and `C-x C-f' have always shared the same history
> variable, `file-name-history'.  Reverting this change to go back to the
> even more broken (IMO) behavior of adding relative file names to the
> history of `C-x C-f' et al.

I agree that the old behavior was broken, and the new fixes it,
but only for `C-x C-f', at the expense of `C-x p f'.

> How about computing the history of `C-x p f' dynamically by filtering
> the elements of `file-name-history' which belong to the current project?
> This is simpler than the other viable solution, to introduce
> project-dependent histories.

This makes sense.  OTOH, sometimes such a need arises to revisit
the same project-relative file in another directory tree
with a similar file structure.  For example, in the directory
with the Emacs master branch visit 'C-x p f lisp/progmodes/project.el'.
Then revisit the same file in the directory with the emacs-29 branch
with 'C-x p f M-p'.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Wed, 14 Dec 2022 16:48:02 GMT) Full text and rfc822 format available.

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

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 58447 <at> debbugs.gnu.org,
 Dmitry Gutov <dgutov <at> yandex.ru>
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Wed, 14 Dec 2022 17:47:26 +0100
On Tue, 13 Dec 2022 at 19:28, Juri Linkov wrote:

> This makes sense.  OTOH, sometimes such a need arises to revisit
> the same project-relative file in another directory tree
> with a similar file structure.  For example, in the directory
> with the Emacs master branch visit 'C-x p f lisp/progmodes/project.el'.
> Then revisit the same file in the directory with the emacs-29 branch
> with 'C-x p f M-p'.

This is an interesting trick.  I have a somewhat related situation: for
some projects, I edit code locally but I can only run it in a remote
(and bigger) machine.  So I have some commands to go back and forth
between the two copies, sync them up, etc.

On the other hand, your trick works by accident.  If you switch between
unrelated projects, then 'C-x p f M-p' brings up a non-existing file.
One might say each project should have its own history, but then it's
not clear whether/when equally named projects in different locations
should count as "the same" project.

Support for "sibling projects" like those would be a interesting but
rather subtle feature that needs to be well thought out.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Wed, 14 Dec 2022 18:46:02 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Augusto Stoffel <arstoffel <at> gmail.com>, Juri Linkov <juri <at> linkov.net>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Wed, 14 Dec 2022 20:45:13 +0200
On 14/12/2022 18:47, Augusto Stoffel wrote:
> On the other hand, your trick works by accident.  If you switch between
> unrelated projects, then 'C-x p f M-p' brings up a non-existing file.
> One might say each project should have its own history, but then it's
> not clear whether/when equally named projects in different locations
> should count as "the same" project.

Perhaps the first step to resolving all this is for project-find-file to 
use a different history variable than find-file.

Which makes sense, given that one (usually) uses relative file names, 
and the other -- absolute ones.

Maybe project--read-file-absolute could continue using the current 
variable, too.

As a result, all projects will share history, for good and bad. Perhaps 
next we could do something about that, e.g. if the history iteration 
could allow pre-filtering, we could also filter out non-existing files.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Wed, 14 Dec 2022 19:33:02 GMT) Full text and rfc822 format available.

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

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 58447 <at> debbugs.gnu.org,
 Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Wed, 14 Dec 2022 20:32:46 +0100
On Wed, 14 Dec 2022 at 20:45, Dmitry Gutov wrote:

> On 14/12/2022 18:47, Augusto Stoffel wrote:
>> On the other hand, your trick works by accident.  If you switch between
>> unrelated projects, then 'C-x p f M-p' brings up a non-existing file.
>> One might say each project should have its own history, but then it's
>> not clear whether/when equally named projects in different locations
>> should count as "the same" project.
>
> Perhaps the first step to resolving all this is for project-find-file
> to use a different history variable than find-file.

This is fine by me, but do you feel confident such a variable will be
a good design for the long run?  In particular, have you discarded the
idea of per-project history variables?

The advantage of my suggestion (filter the file-name-history on the fly)
is that no new variables need to be defined, so nothing needs to be
obsoleted and phased out if we change our minds.

> Which makes sense, given that one (usually) uses relative file names,
> and the other -- absolute ones.
>
> Maybe project--read-file-absolute could continue using the current
> variable, too.
>
> As a result, all projects will share history, for good and
> bad. Perhaps next we could do something about that, e.g. if the
> history iteration could allow pre-filtering, we could also filter out
> non-existing files.

This kind of filtering would be slower than the one I proposed, and
prohibitively slow over Tramp, I think.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Wed, 14 Dec 2022 23:05:01 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 58447 <at> debbugs.gnu.org,
 Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Thu, 15 Dec 2022 01:04:12 +0200
[Message part 1 (text/plain, inline)]
On 14/12/2022 21:32, Augusto Stoffel wrote:
> On Wed, 14 Dec 2022 at 20:45, Dmitry Gutov wrote:
> 
>> On 14/12/2022 18:47, Augusto Stoffel wrote:
>>> On the other hand, your trick works by accident.  If you switch between
>>> unrelated projects, then 'C-x p f M-p' brings up a non-existing file.
>>> One might say each project should have its own history, but then it's
>>> not clear whether/when equally named projects in different locations
>>> should count as "the same" project.
>>
>> Perhaps the first step to resolving all this is for project-find-file
>> to use a different history variable than find-file.
> 
> This is fine by me, but do you feel confident such a variable will be
> a good design for the long run?  In particular, have you discarded the
> idea of per-project history variables?

Just spitballing. And on second thought: probably not.

It's iffy because of the notion of external-roots. The command 
project-or-external-find-file is supposed to reuse the same history, I 
think, and the file names there won't necessarily be relative, or 
relative to the project root. Even in project-find-file the names could 
be relative to a different (nested) dir if there are no files in the top 
dir, and it just has one subdirectory.

> The advantage of my suggestion (filter the file-name-history on the fly)
> is that no new variables need to be defined, so nothing needs to be
> obsoleted and phased out if we change our minds.

Something like let-binding the value of file-hame-history to a different 
value temporarily around completing-read?

That can work, though someone should benchmark it with a large project 
and history.

To resolve the absolute-relative divide, the filtering should be done on 
some higher level. Inside project-find-file-in, perhaps, where we still 
have access to the absolute names, and where we haven't dispatched to 
the configured project-read-file-name-function yet.

>> Which makes sense, given that one (usually) uses relative file names,
>> and the other -- absolute ones.
>>
>> Maybe project--read-file-absolute could continue using the current
>> variable, too.
>>
>> As a result, all projects will share history, for good and
>> bad. Perhaps next we could do something about that, e.g. if the
>> history iteration could allow pre-filtering, we could also filter out
>> non-existing files.
> 
> This kind of filtering would be slower than the one I proposed, and
> prohibitively slow over Tramp, I think.

We're probably talking about the same thing, if the filtering is going 
to use the list of files from project-files, rather than file-exists-p. 
In either case, the user could actually input a non-existent file (or 
file not in the completion table) which would fail that test. But 
they'll hopefully hit C-x C-s soon after.

I've fiddled with the code a little, and here are two different patches.

Patch v1 tries to indeed filter based on what project-files returns.

Problems:

* To call (member s all-files), both absolute file names have to be in 
the same format (i.e. abbreviated v. not). That would require us to 
mandate all project-files implementations, both built-in and 
third-party, to return abbreviated file names. It's a somewhat breaking 
change, and I'm not 100% sure the abbreviated form is useful in more 
situations than the expanded one.

* In a large project, where fetching all files using 'git ls-files' 
takes 1.007258s,

       (seq-filter
        (lambda (s) (member s all-files))
        file-name-history)

takes 0.137352s. That's not huge, but not insignificant either. 
Especially if we someday add some cache for the former computation. This 
could be avoided if 'history-prev-history' had some way to filter 
lazily. And history-item-predicate var, or some such.

* It seems like project-read-file-name-function functions will need to 
do some history conversions on their own anyway, because otherwise they 
insert absolute file names in the prompt.

With the latter in mind, here's a different take (patch v2), which just 
takes care of that.

The patches could be combined, but v1 seems to be too invasive for 
emacs-29, yet v2 could be just small enough to be considered "bugfix-only".

So, what does everyone think about the latter?

If people agree that the v2 patch is an improvement, we can check it in 
and leave project-local histories until later.
[project-find-file-history-v1.diff (text/x-patch, attachment)]
[project-find-file-history-v2.diff (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Thu, 15 Dec 2022 07:32:01 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Augusto Stoffel <arstoffel <at> gmail.com>,
 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Thu, 15 Dec 2022 09:24:51 +0200
> The patches could be combined, but v1 seems to be too invasive for
> emacs-29, yet v2 could be just small enough to be considered "bugfix-only".
>
> So, what does everyone think about the latter?
>
> If people agree that the v2 patch is an improvement, we can check it in and
> leave project-local histories until later.

Does the second patch allow such workflows as re-visiting
the same relative filenames in another directory?

IMHO, the safest fix for emacs-29 would be to add relative filenames
to the separate history.  If someone might want to use
'file-name-history', then a new variable could be added like
'query-replace-from-history-variable'.  Then this variable
could be customized to 'file-name-history', or nil.

It's needed only when 'project-read-file-name-function'
is 'project--read-file-cpd-relative'.

But please also note that its value 'project--read-file-absolute'
is also broken.  It asks confirmation for re-visiting even absolute
filenames, because currently 'C-x p f' adds abbreviated filenames,
but confirmation checks for absolute.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Thu, 15 Dec 2022 11:08:01 GMT) Full text and rfc822 format available.

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

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 58447 <at> debbugs.gnu.org,
 Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Thu, 15 Dec 2022 12:07:14 +0100
On Thu, 15 Dec 2022 at 01:04, Dmitry Gutov wrote:

> We're probably talking about the same thing, if the filtering is going
> to use the list of files from project-files, rather than
> file-exists-p. In either case, the user could actually input a
> non-existent file (or file not in the completion table) which would
> fail that test. But they'll hopefully hit C-x C-s soon after.

My suggestion was not to filer based on project-files, but rather simply
by file name prefixes.  Which, if I read correctly, is exactly what your
patch v2 does.

> The patches could be combined, but v1 seems to be too invasive for
> emacs-29, yet v2 could be just small enough to be considered
> "bugfix-only".
>
> So, what does everyone think about the latter?
>
> If people agree that the v2 patch is an improvement, we can check it
> in and leave project-local histories until later.

In fact I think v2 already is a completely satisfactory implementation
the project-local file history feature.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Thu, 15 Dec 2022 11:09:02 GMT) Full text and rfc822 format available.

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

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 58447 <at> debbugs.gnu.org,
 Dmitry Gutov <dgutov <at> yandex.ru>
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Thu, 15 Dec 2022 12:07:57 +0100
On Thu, 15 Dec 2022 at 09:24, Juri Linkov wrote:

>> The patches could be combined, but v1 seems to be too invasive for
>> emacs-29, yet v2 could be just small enough to be considered "bugfix-only".
>>
>> So, what does everyone think about the latter?
>>
>> If people agree that the v2 patch is an improvement, we can check it in and
>> leave project-local histories until later.
>
> Does the second patch allow such workflows as re-visiting
> the same relative filenames in another directory?

I don't think this should be the default behavior at all.  To me it
seems much more likely that a user _does not_ want to see files from
other projects when doing `C-x p f M-p'.

Your workflow seems more of a job the "find related file" feature that
has been discussed recently in the list.

> IMHO, the safest fix for emacs-29 would be to add relative filenames
> to the separate history.  If someone might want to use
> 'file-name-history', then a new variable could be added like
> 'query-replace-from-history-variable'.  Then this variable
> could be customized to 'file-name-history', or nil.

Then let's do the opposite.  We define 'project-file-history-variable'
and let it be nil by default.  In this case, we get the behavior of
Dmitry's patch v2.  If it's not nil, then we assume it's to be used
as-is, with no filtering or removal of project root prefix.  The user
can set it whatever way they please and take care it makes sense.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Thu, 15 Dec 2022 13:56:02 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Juri Linkov <juri <at> linkov.net>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Augusto Stoffel <arstoffel <at> gmail.com>,
 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Thu, 15 Dec 2022 15:54:58 +0200
On 15/12/2022 09:24, Juri Linkov wrote:
>> The patches could be combined, but v1 seems to be too invasive for
>> emacs-29, yet v2 could be just small enough to be considered "bugfix-only".
>>
>> So, what does everyone think about the latter?
>>
>> If people agree that the v2 patch is an improvement, we can check it in and
>> leave project-local histories until later.
> 
> Does the second patch allow such workflows as re-visiting
> the same relative filenames in another directory?

Not really; it filters by project root (more or less).

As long as we have global history, it's hard to extract the relative 
names for it, if they belong to a different directory tree.

But the history storage seems to retain text properties. So I suppose 
one option would be to annotate the "relative" part with a text 
property, before adding the string to history. And then look up the text 
property later.

> IMHO, the safest fix for emacs-29 would be to add relative filenames
> to the separate history.  If someone might want to use
> 'file-name-history', then a new variable could be added like
> 'query-replace-from-history-variable'.  Then this variable
> could be customized to 'file-name-history', or nil.
> 
> It's needed only when 'project-read-file-name-function'
> is 'project--read-file-cpd-relative'.

It can work, but having a user option that only works for 
project--read-file-cpd-relative is pretty awkward. Beginning with having 
to choose its name.

If we do this, I'd rather that happens on master, and we choose 
something smaller for emacs-29.

And the text property trick above could both "store" the relative 
history and also keep adding entries to 'C-x C-f'.

> But please also note that its value 'project--read-file-absolute'
> is also broken.  It asks confirmation for re-visiting even absolute
> filenames, because currently 'C-x p f' adds abbreviated filenames,
> but confirmation checks for absolute.

Does the breakage show itself only when you add a history entry using 
one value of project-read-file-name-function and then try to look it up 
when using another value of project-read-file-name-function?

If so, that's probably bearable enough for now (people don't really 
change this value often). Fixing it will require resolving the 
abbreviation situation. And we might as well switch to relative names in 
project-files first.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Thu, 15 Dec 2022 14:05:01 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Augusto Stoffel <arstoffel <at> gmail.com>, Juri Linkov <juri <at> linkov.net>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Thu, 15 Dec 2022 16:04:13 +0200
On 15/12/2022 13:07, Augusto Stoffel wrote:
> On Thu, 15 Dec 2022 at 09:24, Juri Linkov wrote:
> 
>>> The patches could be combined, but v1 seems to be too invasive for
>>> emacs-29, yet v2 could be just small enough to be considered "bugfix-only".
>>>
>>> So, what does everyone think about the latter?
>>>
>>> If people agree that the v2 patch is an improvement, we can check it in and
>>> leave project-local histories until later.
>>
>> Does the second patch allow such workflows as re-visiting
>> the same relative filenames in another directory?
> 
> I don't think this should be the default behavior at all.  To me it
> seems much more likely that a user _does not_ want to see files from
> other projects when doing `C-x p f M-p'.

Do you think they will mind too much? At least if the relative names are 
shown, the user will recognize them and won't be too surprised.

> Your workflow seems more of a job the "find related file" feature that
> has been discussed recently in the list.
> 
>> IMHO, the safest fix for emacs-29 would be to add relative filenames
>> to the separate history.  If someone might want to use
>> 'file-name-history', then a new variable could be added like
>> 'query-replace-from-history-variable'.  Then this variable
>> could be customized to 'file-name-history', or nil.
> 
> Then let's do the opposite.  We define 'project-file-history-variable'
> and let it be nil by default.  In this case, we get the behavior of
> Dmitry's patch v2.  If it's not nil, then we assume it's to be used
> as-is, with no filtering or removal of project root prefix.  The user
> can set it whatever way they please and take care it makes sense.

The problem with that is storing relative history in such a variable 
will only work with one of the values of 
project-read-file-name-function. So we'll have two defcustoms which need 
to be changed in concert..?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Thu, 15 Dec 2022 14:09:01 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 58447 <at> debbugs.gnu.org,
 Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Thu, 15 Dec 2022 16:08:04 +0200
On 15/12/2022 13:07, Augusto Stoffel wrote:
> On Thu, 15 Dec 2022 at 01:04, Dmitry Gutov wrote:
> 
>> We're probably talking about the same thing, if the filtering is going
>> to use the list of files from project-files, rather than
>> file-exists-p. In either case, the user could actually input a
>> non-existent file (or file not in the completion table) which would
>> fail that test. But they'll hopefully hit C-x C-s soon after.
> My suggestion was not to filer based on project-files, but rather simply
> by file name prefixes.  Which, if I read correctly, is exactly what your
> patch v2 does.

Ah yes.

>> The patches could be combined, but v1 seems to be too invasive for
>> emacs-29, yet v2 could be just small enough to be considered
>> "bugfix-only".
>>
>> So, what does everyone think about the latter?
>>
>> If people agree that the v2 patch is an improvement, we can check it
>> in and leave project-local histories until later.
> In fact I think v2 already is a completely satisfactory implementation
> the project-local file history feature.

It seems like there are two incompatible behaviors here and you and Juri 
want. One is to filter by current project, and another to be able to 
reuse previous inputs freely.

If forced to choose, I would be slightly inclined toward the latter 
(which could be implemented using text properties, although the concept 
is a little awkward). But both are reasonable.

I think we should install one of them and then later (on master) add a 
user option to switch to the other behavior.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Thu, 15 Dec 2022 17:40:03 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Augusto Stoffel <arstoffel <at> gmail.com>,
 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Thu, 15 Dec 2022 19:21:14 +0200
>> In fact I think v2 already is a completely satisfactory implementation
>> the project-local file history feature.
>
> It seems like there are two incompatible behaviors here and you and Juri
> want. One is to filter by current project, and another to be able to reuse
> previous inputs freely.
>
> If forced to choose, I would be slightly inclined toward the latter (which
> could be implemented using text properties, although the concept is
> a little awkward). But both are reasonable.
>
> I think we should install one of them and then later (on master) add a user
> option to switch to the other behavior.

I agree with Augusto that filtering that implements project-local history
should be the default behavior for emacs-29.  I tried your second patch
and it nicely handles even such sequences as `C-x p f' and `C-x p F'.
(and in the opposite direction from `C-x p F' to `C-x p f' it
filters out external files, that is expected and consistent.)

OTOH, `C-x p f M-p' in another project is not my primary workflow.
But if someone wants to keep a plain history, this could be added
later in master, e.g. by a new value of project-read-file-name-function
and a function that is mostly a copy of project--read-file-cpd-relative.

BTW, in a fresh emacs -Q `C-x p f' raises:
  Debugger entered--Lisp error: (void-function cl-find-if)
But not sure how important is this case since usually `C-x p f'
is invoked on a project's file when project.el with cl is loaded.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Thu, 15 Dec 2022 17:40:04 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Augusto Stoffel <arstoffel <at> gmail.com>,
 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Thu, 15 Dec 2022 19:24:24 +0200
>> But please also note that its value 'project--read-file-absolute'
>> is also broken.  It asks confirmation for re-visiting even absolute
>> filenames, because currently 'C-x p f' adds abbreviated filenames,
>> but confirmation checks for absolute.
>
> Does the breakage show itself only when you add a history entry using one
> value of project-read-file-name-function and then try to look it up when
> using another value of project-read-file-name-function?
>
> If so, that's probably bearable enough for now (people don't really change
> this value often). Fixing it will require resolving the abbreviation
> situation. And we might as well switch to relative names in project-files
> first.

Visiting with 'C-x C-f' adds an abbreviated file name to the history.
So it looks strange that 'C-x p f M-p' doesn't understand that it's
absolute even though it's abbreviated.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Thu, 15 Dec 2022 22:21:02 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Juri Linkov <juri <at> linkov.net>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Augusto Stoffel <arstoffel <at> gmail.com>,
 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Fri, 16 Dec 2022 00:20:47 +0200
On 15/12/2022 19:24, Juri Linkov wrote:
>>> But please also note that its value 'project--read-file-absolute'
>>> is also broken.  It asks confirmation for re-visiting even absolute
>>> filenames, because currently 'C-x p f' adds abbreviated filenames,
>>> but confirmation checks for absolute.
>> Does the breakage show itself only when you add a history entry using one
>> value of project-read-file-name-function and then try to look it up when
>> using another value of project-read-file-name-function?
>>
>> If so, that's probably bearable enough for now (people don't really change
>> this value often). Fixing it will require resolving the abbreviation
>> situation. And we might as well switch to relative names in project-files
>> first.
> Visiting with 'C-x C-f' adds an abbreviated file name to the history.
> So it looks strange that 'C-x p f M-p' doesn't understand that it's
> absolute even though it's abbreviated.

Fair enough.

Can we do something with it, though, without piping all-files through 
#'expand-file-name?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Thu, 15 Dec 2022 22:52:02 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Juri Linkov <juri <at> linkov.net>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Augusto Stoffel <arstoffel <at> gmail.com>,
 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Fri, 16 Dec 2022 00:50:58 +0200
On 15/12/2022 19:21, Juri Linkov wrote:
>>> In fact I think v2 already is a completely satisfactory implementation
>>> the project-local file history feature.
>>
>> It seems like there are two incompatible behaviors here and you and Juri
>> want. One is to filter by current project, and another to be able to reuse
>> previous inputs freely.
>>
>> If forced to choose, I would be slightly inclined toward the latter (which
>> could be implemented using text properties, although the concept is
>> a little awkward). But both are reasonable.
>>
>> I think we should install one of them and then later (on master) add a user
>> option to switch to the other behavior.
> 
> I agree with Augusto that filtering that implements project-local history
> should be the default behavior for emacs-29.  I tried your second patch
> and it nicely handles even such sequences as `C-x p f' and `C-x p F'.
> (and in the opposite direction from `C-x p F' to `C-x p f' it
> filters out external files, that is expected and consistent.)

That sounds like a consensus, then. I've pushed the v2 patch to emacs-29.

> OTOH, `C-x p f M-p' in another project is not my primary workflow.
> But if someone wants to keep a plain history, this could be added
> later in master, e.g. by a new value of project-read-file-name-function
> and a function that is mostly a copy of project--read-file-cpd-relative.
> 
> BTW, in a fresh emacs -Q `C-x p f' raises:
>    Debugger entered--Lisp error: (void-function cl-find-if)
> But not sure how important is this case since usually `C-x p f'
> is invoked on a project's file when project.el with cl is loaded.

...and included a fix for this too. Thanks!




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Fri, 16 Dec 2022 07:50:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Augusto Stoffel <arstoffel <at> gmail.com>,
 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Fri, 16 Dec 2022 09:48:09 +0200
>>>> But please also note that its value 'project--read-file-absolute'
>>>> is also broken.  It asks confirmation for re-visiting even absolute
>>>> filenames, because currently 'C-x p f' adds abbreviated filenames,
>>>> but confirmation checks for absolute.
>>> Does the breakage show itself only when you add a history entry using one
>>> value of project-read-file-name-function and then try to look it up when
>>> using another value of project-read-file-name-function?
>>>
>>> If so, that's probably bearable enough for now (people don't really change
>>> this value often). Fixing it will require resolving the abbreviation
>>> situation. And we might as well switch to relative names in project-files
>>> first.
>> Visiting with 'C-x C-f' adds an abbreviated file name to the history.
>> So it looks strange that 'C-x p f M-p' doesn't understand that it's
>> absolute even though it's abbreviated.
>
> Fair enough.
>
> Can we do something with it, though, without piping all-files through
> #'expand-file-name?

In theory, it should be sufficient to pipe through #'expand-file-name
only the completion candidate to try both with and without
#'expand-file-name.  But in practice this might require
implementing this as the CONFIRM function.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Sun, 18 Dec 2022 00:33:01 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Juri Linkov <juri <at> linkov.net>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Augusto Stoffel <arstoffel <at> gmail.com>,
 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Sun, 18 Dec 2022 02:32:34 +0200
On 16/12/2022 09:48, Juri Linkov wrote:
>> Can we do something with it, though, without piping all-files through
>> #'expand-file-name?
> In theory, it should be sufficient to pipe through #'expand-file-name
> only the completion candidate to try both with and without
> #'expand-file-name.  But in practice this might require
> implementing this as the CONFIRM function.

Either that, or indeed modify the completion table inside 
project--file-completion-table.

Not sure which is easier to do and/or more compatible with the different 
completion frameworks out there.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Sun, 18 Dec 2022 09:12:01 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Augusto Stoffel <arstoffel <at> gmail.com>,
 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Sun, 18 Dec 2022 10:36:48 +0200
>> I agree with Augusto that filtering that implements project-local history
>> should be the default behavior for emacs-29.  I tried your second patch
>> and it nicely handles even such sequences as `C-x p f' and `C-x p F'.
>> (and in the opposite direction from `C-x p F' to `C-x p f' it
>> filters out external files, that is expected and consistent.)
>
> That sounds like a consensus, then. I've pushed the v2 patch to emacs-29.

Thanks.  One very minor detail: when the history contains the project root
directory then it's confusing to see that M-p does nothing.  It looks like
it has no effect because it inserts an empty string.  Maybe better to
filter out empty strings?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Sun, 18 Dec 2022 11:52:01 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Juri Linkov <juri <at> linkov.net>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Augusto Stoffel <arstoffel <at> gmail.com>,
 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Sun, 18 Dec 2022 13:51:01 +0200
On 18/12/2022 10:36, Juri Linkov wrote:
> It looks like
> it has no effect because it inserts an empty string.  Maybe better to
> filter out empty strings?

Sure. Do you want to implement that?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Mon, 19 Dec 2022 17:57:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Augusto Stoffel <arstoffel <at> gmail.com>,
 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Mon, 19 Dec 2022 19:55:22 +0200
>> It looks like
>> it has no effect because it inserts an empty string.  Maybe better to
>> filter out empty strings?
>
> Sure. Do you want to implement that?

Done in commit 399433cc2b9.

Also noticed that project-find-dir (that uses the same
project--read-file-cpd-relative) needs to filter out
all file names, leaving only directory names in the
pre-processed history.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Mon, 19 Dec 2022 18:02:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: arstoffel <at> gmail.com, 58447 <at> debbugs.gnu.org, dgutov <at> yandex.ru
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Mon, 19 Dec 2022 20:01:33 +0200
> From: Juri Linkov <juri <at> linkov.net>
> Cc: Eli Zaretskii <eliz <at> gnu.org>,  Augusto Stoffel <arstoffel <at> gmail.com>,
>   58447 <at> debbugs.gnu.org
> Date: Mon, 19 Dec 2022 19:55:22 +0200
> 
> >> It looks like
> >> it has no effect because it inserts an empty string.  Maybe better to
> >> filter out empty strings?
> >
> > Sure. Do you want to implement that?
> 
> Done in commit 399433cc2b9.

How about making the code there a bit more efficient by computing
(length abbr-cpd) just once instead of twice?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Mon, 19 Dec 2022 19:19:02 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Juri Linkov <juri <at> linkov.net>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Augusto Stoffel <arstoffel <at> gmail.com>,
 58447 <at> debbugs.gnu.org
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Mon, 19 Dec 2022 21:18:22 +0200
On 19/12/2022 19:55, Juri Linkov wrote:
> Also noticed that project-find-dir (that uses the same
> project--read-file-cpd-relative) needs to filter out
> all file names, leaving only directory names in the
> pre-processed history.

That will probably be an improvement, yes.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Mon, 19 Dec 2022 19:49:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: arstoffel <at> gmail.com, 58447 <at> debbugs.gnu.org, dgutov <at> yandex.ru
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Mon, 19 Dec 2022 21:48:20 +0200
>> >> It looks like
>> >> it has no effect because it inserts an empty string.  Maybe better to
>> >> filter out empty strings?
>> >
>> > Sure. Do you want to implement that?
>> 
>> Done in commit 399433cc2b9.
>
> How about making the code there a bit more efficient by computing
> (length abbr-cpd) just once instead of twice?

Fixed.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58447; Package emacs. (Mon, 19 Dec 2022 20:01:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: arstoffel <at> gmail.com, 58447 <at> debbugs.gnu.org, dgutov <at> yandex.ru
Subject: Re: bug#58447: [PATCH] In project-find-file, add absolute file name
 to history
Date: Mon, 19 Dec 2022 22:00:08 +0200
> From: Juri Linkov <juri <at> linkov.net>
> Cc: dgutov <at> yandex.ru,  arstoffel <at> gmail.com,  58447 <at> debbugs.gnu.org
> Date: Mon, 19 Dec 2022 21:48:20 +0200
> 
> > How about making the code there a bit more efficient by computing
> > (length abbr-cpd) just once instead of twice?
> 
> Fixed.

Thanks.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 17 Jan 2023 12:24:07 GMT) Full text and rfc822 format available.

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

Previous Next


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