Subject: bug#65704: 29.1; Most code of `project-ignores' seems to be dead code

From: Damien Cassou <[email-masked]>
Date: Mon, 04 Sep 2023 18:03:04 +0200

Dmitry Gutov <[email-masked]> writes:
> much. Maybe just that that code path isn't exercised by any in-tree
> function if the backend is Git (with recent enough git installed)

My Git repository has several .gitignore files in several directories,
something that `project-ignores' (for VC) seems to not support:

    ;; we only support .gitignore at the root.

My project looks like this:

.
├── client
│   ├── .gitignore
│   ├── node_modules
│   └── .project
├── .git
└── .gitignore

Because I spend most of my time in the client/ directory, I want the
`project' library to consider client/ to be a project on its own. I use
the code below and the client/.project file to do this:

    (defconst my/project-root-marker ".project"
      "File indicating the root of a project.")

    (defun my/project-find-root (path)
      "Search up the PATH for `my/project-root-marker'."
      (when-let* ((root (locate-dominating-file path my/project-root-marker)))
        (cons 'transient root)))

    (add-to-list 'project-find-functions #'my/project-find-root)

The client/.gitignore file contains a line "node_modules/" which is a
very large directory. The command `project-find-file' doesn't see my
client/.gitignore and thus suggests 83k files and make the completion UI
very slow. So I'm not using it but this instead:

  (project-find-file-in (thing-at-point 'filename)
                        (list "/my/project/client")
                        (project-current nil "/my/project"))

The function `project-find-file-in' uses `project-files' which in turn
uses `project--dir-ignores'. The later uses `project-ignores' which has
the bug mentioned in this issue.

Am I doing something reasonable? Is there a better way? It looks like a
lot of setup to get Emacs to ignore directories listed .gitignore files.

-- 
Damien Cassou

"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill