emacs-devel
[Top][All Lists]
Advanced

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

Re: New feature in project.el: Remembering the previously used projects


From: Dmitry Gutov
Subject: Re: New feature in project.el: Remembering the previously used projects
Date: Sat, 30 May 2020 02:22:00 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0

On 30.05.2020 01:55, Kévin Le Gouguec wrote:

I have one gripe with it though: I've rigged frame-title-format to show
the basename of the project root directory[1], which means I have a call
to project-current on every redisplay.

First thought: you can cache it based it the value of default-directory. Which should cut down on these calls (which trigger directory traversals, etc) dramatically, and should be an improvement either way.

IIUC, when default-directory is inside a project, project-current now
calls project--add-to-project-list-front, which in turn calls
project--write-project-list.

This slows down redisplay quite noticeably on my end[2].  I don't know
what the best solution would be; does it sound acceptable to add an
optional SKIP-LIST-UPDATE argument for project-current, or is it too
much trouble for this peculiar use-case?

And another thought: maybe we should only add a project to the project list if user interaction happened (i.e. going through project-prompt-project-dir). Simen, what do you think?

The patch below mostly does that, except it misses the case when a directory was selected from project-switch-project. To fix that, we could either duplicate the bit of logic there, or undo, in part, the commit 9f88356b6770fb710c47e277dbdb4ba31b463d08 (turn project-prompt-project-dir back into project-prompt-project, to return a project instance, and handle the addition to history in there).

Anyway, the quick patch:

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 1f2a4e8471..2611b04680 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -114,10 +114,11 @@ project-current
      ((unless project-current-inhibit-prompt
         maybe-prompt)
       (setq dir (project-prompt-project-dir)
-            pr (project--find-in-directory dir))))
-    (if pr
-        (project--add-to-project-list-front pr)
-      (project--remove-from-project-list dir)
+            pr (project--find-in-directory dir))
+      (if pr
+          (project--add-to-project-list-front pr)
+        (project--remove-from-project-list dir))))
+    (unless pr
       (setq pr (cons 'transient dir)))
     pr))




reply via email to

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