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

From: Dmitry Gutov <[email-masked]>
Date: Mon, 30 Sep 2024 04:50:38 +0300

On 13/08/2024 17:50, Ship Mints wrote:
> As some food for thought, we've used git attributes via "git check-attr" 
> to record custom metadata at the repository level to provide hints to 
> tooling. As project.el and other tools evolve, perhaps we can consider 
> the cases where users can supply functions that influence behavior where 
> one use case is based on things like git attributes. The case in hand is 
> whether a submodule should be considered external to a project.el 
> project such as the vendor/third-party submodule I'd mentioned. We use 
> the default project-vc-merge-submodules t and our exceptions could be 
> encoded via a custom git attribute and indicated via a predicate 
> function, perhaps. In the absence of formal guidelines, and git does not 
> seem to define "reserved words" for naming, we prefix custom attributes 
> with an underscore.

Git attributes is a possible approach, with a downside of extra process 
calls, which over Tramp (for example) would mean additional latency.

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.

I kind of hoped this would work automatically, it does not, but adding 
the extra comparisons against the list of ignores seems natural enough.

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 599a350e5ce..79fcfb65f87 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -720,7 +731,9 @@ project--vc-list-files
           (let ((sub-files
                  (mapcar
                   (lambda (module)
-                   (when (file-directory-p module)
+                   (when (and (file-directory-p module)
+                              ;; TODO: Support real globs.
+                              (not (member module extra-ignores)))
                       (let ((sub-files
                              (project--vc-list-files
                               (concat default-directory module)