On Sun, Sep 29, 2024 at 9:50 PM Dmitry Gutov <dmitry@gutov.dev> wrote:
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.

(defun project--value-in-dir (var dir) already incurs latency over tramp, right?
 
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 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)