]> git.eshelyaron.com Git - emacs.git/commitdiff
Write project list to file only when changed
authorSimen Heggestøyl <simenheg@gmail.com>
Tue, 2 Jun 2020 17:20:14 +0000 (19:20 +0200)
committerSimen Heggestøyl <simenheg@gmail.com>
Tue, 2 Jun 2020 17:27:55 +0000 (19:27 +0200)
* lisp/progmodes/project.el (project--add-to-project-list-front):
Write the project list to file only when it has changed.

lisp/progmodes/project.el

index 314918901eaf6f6d7dcdd3818f7095943743de7a..0051a84ff846b34f550dd117b7e4c3fe6ef7e826 100644 (file)
@@ -771,14 +771,15 @@ Arguments the same as in `compile'."
       (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.