[Top][All Lists]

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

Re: Subprojects in project.el (Was: Eglot, project.el, and python virtua

From: Dmitry Gutov
Subject: Re: Subprojects in project.el (Was: Eglot, project.el, and python virtual environments)
Date: Fri, 25 Nov 2022 00:17:54 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2

On 24/11/22 10:42, João Távora wrote:
On Thu, Nov 24, 2022 at 2:49 AM Dmitry Gutov <dgutov@yandex.ru <mailto:dgutov@yandex.ru>> wrote:

    On 23/11/22 22:33, João Távora wrote:
     > For my idea to work, project-current would have to be changed to
     > 1. Call all members of project-find-functions: return the innermost
     >     project found thus far.
     > 2. Not call project-find-functions recursively when called from
    within a
     > function
     >     in project-find-functions, just return the innermost project
     >     thus far.
     > I don't see any big performance problems in this alternative.

    Might not be much of a difference in a simple configuration, but going
    up and down dirs is not free even on a fast SSD, especially as the
    number of the elements on this hook grows.

    But where you will definitely see a difference, is when using this with

Have you seen the code I posted? You'll notice that it doesn't do
any file system operations, it just does file name operations. And
those run in CPU/memory, not file system. So I cannot understand
your argument.  But I am happy to measure performance in different
scenarios, if you'd like to suggest a particularly problematic one.

I am commenting here on the idea to "Call all members of project-find-functions". Members of project-find-functions do file system operations.

And that's what your piece of code does (call all members):

+(defvar project--overriding-projects nil)
 (defun project--find-in-directory (dir)
-  (run-hook-with-args-until-success 'project-find-functions dir))
+  "Find projects that directory DIR belongs to.
+Return them as a list.  If more than one is found, the first is
+usually the innermost."
+  (or project--overriding-projects
+      (let (projects)
+        (run-hook-wrapped
+         'project-find-functions
+         (lambda (fn)
+           (let* ((project--overriding-projects projects)
+                  (prj (funcall fn dir)))
+             (when prj (push prj projects)))
+           nil))
+        projects)))

reply via email to

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