emacs-devel
[Top][All Lists]
Advanced

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

Re: Subprojects in project.el


From: Dmitry Gutov
Subject: Re: Subprojects in project.el
Date: Sat, 26 Nov 2022 15:34:25 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2

On 26/11/22 11:23, João Távora wrote:
Dmitry Gutov <dgutov@yandex.ru> writes:

On 26/11/22 02:00, João Távora wrote:

We aren't even close to top efficiency WRT file operations now. And
your idea is also based on hand-crafting project-find-functions to
only contain the necessary items.

project-find-functions is part of project.el's API.  So it makes a lot
of sense to use, otherwise why would it be there?  We can provide some
pre-baked functions to put there, or already put there for users.  The
key point is that functions bail out early if they don't the adequate
context.  One of them is the one I proposed earlier, which uses a local
project-subproject-prefixes variable.  Another would search for marker
files and consult a tramp-specific user variable for opt-out.

project-find-functions up until now has worked like many other hooks we have (e.g. completion-at-point-functions): the first element that returns non-nil is used, the others are not paid attention.

That allows these hooks to be used by major and minor modes, rather than having the user curate the full list. As long as priorities are set correctly, the system works. E.g. projectile-mode can just add its own element at the beginning, and not worry about stuff that already exists there.

As opposed to real-life scenario of Projectile just adding its
function at the front.

I don't entirely understand the algorithm you're proposing here, but
it sounds vaguely like what I'm writing now, so you might like the
result.
Where/when can I find this code?

You and others can now find it here: https://debbugs.gnu.org/41572#186

That thread has a latest patch that allows marker files to designate
top-level projects: I'm not interested in using marker files
specifically, so I don't see the relevance.  I can't deduce from the
patch what you're trying to solve or if it solves my use case.

Previously you said:

> Fwiw, Danny's tip is what I used at a recent day job gig for defining subprojects in a 400k files repo.

where Danny's snippet looked like:

  (defun project-find-project.el (dir)
    "Returns a `manual-project' instance if the project of the current
  DIR has a .project.el file in its root directory."
    (let ((root (locate-dominating-file dir ".project.el")))
      (when root
        (cons 'transient root))))

  (add-hook 'project-find-functions #'project-find-project.el)

...but you didn't use marker files? Or you don't want to use them anymore? I'm really confused here.



reply via email to

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