bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#66993: [PATCH] project.el: avoid asking user about project-list-file


From: Dmitry Gutov
Subject: bug#66993: [PATCH] project.el: avoid asking user about project-list-file lock
Date: Wed, 8 Nov 2023 02:24:13 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0

On 07/11/2023 23:28, Spencer Baugh wrote:
- project-mode-line will call this on mode-line update

Hopefully this will never result in writes to disk made more often than once per user command, or buffer switch, etc.

-      (write-region nil nil filename nil 'silent))))
+      ;; If project-list-file is locked by some other Emacs, fail to
+      ;; write rather than prompting the user.
+      (ignore-error file-locked
+        (cl-letf (((symbol-function 'ask-user-about-lock)
+                   (lambda (file opponent)
+                     (signal 'file-locked (list file opponent)))))
+          (write-region nil nil filename nil 'silent))))))

I wonder if all cl-letf uses like this will survive native compilation, for example. Or will break over time due to internal changes in the function.

Anyway, maybe an implementation like this (totally untested)?

Or the warning could be skipped entirely.

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index a6426c08840..e544dfefa73 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1719,7 +1719,9 @@ project--write-project-list
                                 (expand-file-name name)))))
                     project--list)
             (current-buffer)))
-      (write-region nil nil filename nil 'silent))))
+      (let ((noninteractive t))
+        (with-demoted-errors "Failed to save file list: %S"
+          (write-region nil nil filename nil 'silent))))))

 ;;;###autoload
 (defun project-remember-project (pr &optional no-write)







reply via email to

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