Subject: bug#72300: project.el: detect newly created project contained within another

From: Dmitry Gutov <[email-masked]>
Date: Tue, 1 Oct 2024 02:10:31 +0300

On 30/09/2024 17:31, Ship Mints wrote:

>     Git attributes is a possible approach, with a downside of extra process
>     calls, which over Tramp (for example) would mean additional latency.
> 
> 
> (defun project--value-in-dir (var dir)already incurs latency over tramp, 
> right?

Yep, but almost every other separate I/O adds to it. So with other 
things equal, I'd prefer solutions with fewer disk reads - at least for 
the default behavior.

>     How about we just support filtering out submodules using the
>     project-vc-ignores var? Which can be assigned in .dir-locals.el or
>     through other means.
> 
> 
> Seems simple. Perhaps an abnormal hook so people can customize buffer 
> local hook via dir locals? If they want to use git attributes, they 
> could integrate that approach as an added/replacement function. The 
> function list could default to a function that implements current behavior.

I'd like to say yes, but what would be a good place and name for that hook?

Note there is an existing hook called before-hack-local-variables-hook 
which allows one to alter the applied local variables. But that one 
might run more often than ideal - perhaps try it out and report back.

Another approach might use a custom project backend which wraps the 
existing project-vc - it would need to provide a custom implementation 
for 'project-ignores' and could delegate the rest of the methods to the 
parent.

BTW, are you asking about using git attributes because there is an 
existing workflow that somehow hooks into it, at some of your clients? 
If not, then editing dir-locals.el to set the value of 
project-vc-ignores directly seems like an easier approach.