bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#63829: 29.0.90; project-find-file's future history breaks with commo


From: sbaugh
Subject: bug#63829: 29.0.90; project-find-file's future history breaks with common-parent-directory
Date: Wed, 16 Aug 2023 02:57:18 +0000 (UTC)
User-agent: Gnus/5.13 (Gnus v5.13)

Dmitry Gutov <dmitry@gutov.dev> writes:
> On 15/08/2023 01:47, sbaugh@catern.com wrote:
>
>>>>> I'm not sure I understand the alternative - the idea would be to share
>>>>> project file name history between all projects?  I guess that could be
>>>>> nice, although I don't personally use file name history that much, and
>>>>> AFAIK it wouldn't solve any concrete user problems, so I'm not really
>>>>> motivated to implement it.
>>>>
>>>> The alternative is a little more general, e.g. propertize every such
>>>> history entry with the value of the root, so that they can be
>>>> post-processed to adapt to any other root directory.
>>>>
>>>> This shouldn't take too much work, actually. But I don't know if that
>>>> is indeed a necessary feature. From the discussion
>>>> (https://debbugs.gnu.org/58447), I had been under impression that it
>>>> would be wanted, but it might be just "nice to have".
>>>
>>> I would be happy to do that.  That sounds very cool actually.
>>>
>>> Can you elaborate on how exactly you imagine this happening?  I guess,
>>> every time someone enters a filename with project-find-file or
>>> project-find-dir, we would include a propertized version of that
>>> filename in file-name-history?  And then we would re-relativize them and
>>> adapt them to the current project when including them as history?
>> Okay, I did that.  Extremely rough patch follows.
>
> Thanks! It's very close to what I was thinking of (modulo some
> cosmetics and perf optimizations).
>
>> Btw, the reason I'm interested in this shared project history is because
>> our workflow involves creating many new projects (one per branch); so
>> mostly each project has no history at all, and sharing history between
>> projects is the only way to get any.
>
> Now that you can have this additional capability as an option, do you
> think you will be using it as well?

Yes, probably I will enable this shared project history mode for my
users.

>> But, it seems to me that this doesn't really help with having the
>> current file be "future history".  That's still useful when switching
>> between similar projects.  And all the logic of my other patch which
>> does that, is still required with this patch.
>
> Indeed, that's a good point. So I think we'll install your first patch
> either way.
>
> Before we do that, small (or not so small) question: do you think we
> should test that the current buffer exists in the other project too?
> We could do that with file-exists-p (but that's an extra round-trip
> over Tramp), or by checking against the full list like in below.

No, I don't think that's necessary.  It produces more consistent
behavior to not check whether the file exists.  And anyway, it could
maybe be helpful to be able to create the same file in another project.

> Relatedly, with the cross-project history, we should ask the same
> question: will we check that the "transplanted" history entries
> correspond to existing files in the other project (and filter out
> those that don't).

Likewise I don't think that's necessary.

Although it might be nice to support a user-supplied predicate which,
given the current project and a path in the history (which contains as a
property the originating project), determines whether to show that path.
Then the user could filter the history to only paths in "sibling
projects" with similar content.  Not required though.

> WDYT?
>
> diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
> index d8b12c9c880..a32bc2dd8d3 100644
> --- a/lisp/progmodes/project.el
> +++ b/lisp/progmodes/project.el
> @@ -1116,7 +1116,10 @@ project-find-file-in
>           (completion-ignore-case read-file-name-completion-ignore-case)
>           (file (funcall project-read-file-name-function
>                          "Find file" all-files nil 'file-name-history
> -                        suggested-filename)))
> +                        (if (file-name-absolute-p suggested-filename)
> +                            (and (member suggested-filename all-files)
> +                                 suggested-filename)
> +                          suggested-filename))))
>      (if (string= file "")
>          (user-error "You didn't specify the file")
>        (find-file file))))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]