[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: New feature in project.el: Remembering the previously used projects
From: |
Simen Heggestøyl |
Subject: |
Re: New feature in project.el: Remembering the previously used projects |
Date: |
Sat, 30 May 2020 08:05:25 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.91 (gnu/linux) |
Dmitry Gutov <dgutov@yandex.ru> writes:
> 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. [...]
Hm, I think it misses all cases when project-switch-project is used,
since project-current will find the project using
project--find-in-directory (project-switch-project already did the
prompting part).
Maybe a simple solution could be to only write to the file when the
addition caused the project list to change? I think it's a good change
regardless, but is it enough to fix your issue, Kévin?
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 1f2a4e8471..a2ef84e444 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -751,14 +751,15 @@ project--write-project-list
(write-region nil nil filename nil 'silent))))
(defun project--add-to-project-list-front (pr)
- "Add project PR to the front of the project list and save it.
-Return PR."
+ "Add project PR to the front of the project list.
+Save the result to disk if the project list was changed."
(project--ensure-read-project-list)
- (let ((dir (project-root pr)))
+ (let* ((dir (project-root pr))
+ (do-write (not (equal (car project--list) dir))))
(setq project--list (delete dir project--list))
- (push dir project--list))
- (project--write-project-list)
- pr)
+ (push dir project--list)
+ (when do-write
+ (project--write-project-list))))
(defun project--remove-from-project-list (pr-dir)
"Remove directory PR-DIR from the project list.
Dmitry Gutov <dgutov@yandex.ru> writes:
> Alternatively, we could defer writing the file until Emacs is being
> closed (and do that in kill-emacs-hook).
Maybe. I think doing it more eagerly has some advantages though if we
can make it work:
- Launching a new Emacs session while another one is running will use
the latest project list.
- If there's any problem writing to the file I imagine it's better to be
notified about it up front rather than at the time Emacs is killed.
-- Simen
- Re: New feature in project.el: Remembering the previously used projects, (continued)
- Re: New feature in project.el: Remembering the previously used projects, Dmitry Gutov, 2020/05/28
- Re: New feature in project.el: Remembering the previously used projects, Philip K., 2020/05/29
- Re: New feature in project.el: Remembering the previously used projects, Dmitry Gutov, 2020/05/29
- Re: New feature in project.el: Remembering the previously used projects, Simen Heggestøyl, 2020/05/29
- Re: New feature in project.el: Remembering the previously used projects, Philip K., 2020/05/30
- Re: New feature in project.el: Remembering the previously used projects, Dmitry Gutov, 2020/05/30
Re: New feature in project.el: Remembering the previously used projects, Kévin Le Gouguec, 2020/05/29
- Re: New feature in project.el: Remembering the previously used projects, Dmitry Gutov, 2020/05/29
- Message not available
- Re: New feature in project.el: Remembering the previously used projects, Kévin Le Gouguec, 2020/05/30
- Re: New feature in project.el: Remembering the previously used projects, Dmitry Gutov, 2020/05/30
- Re: New feature in project.el: Remembering the previously used projects, Dmitry Gutov, 2020/05/30
- Re: New feature in project.el: Remembering the previously used projects, Kévin Le Gouguec, 2020/05/30