branch: externals/org
commit dc485a65906dbb0f66066fb807fa93870c310e33
Author: Ihor Radchenko <[email protected]>
Commit: Ihor Radchenko <[email protected]>

    lisp/org-persist.el: Ignore lock files when writing cache
    
    * lisp/org-persist.el (org-persist--write-elisp-file): Ignore locks.
    
    Reported-by: Greg Minshall <[email protected]>
    Link: https://orgmode.org/list/574109.1715751441@archlinux
---
 lisp/org-persist.el | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/lisp/org-persist.el b/lisp/org-persist.el
index 824f811f3f..9f2fd3424c 100644
--- a/lisp/org-persist.el
+++ b/lisp/org-persist.el
@@ -476,12 +476,17 @@ FORMAT and ARGS are passed to `message'."
         (start-time (float-time)))
     (unless (file-exists-p (file-name-directory file))
       (make-directory (file-name-directory file) t))
-    (with-temp-file file
-      (insert ";;   -*- mode: lisp-data; -*-\n")
-      (if pp
-          (let ((pp-use-max-width nil)) ; Emacs bug#58687
-            (pp data (current-buffer)))
-        (prin1 data (current-buffer))))
+    ;; Force writing even when the file happens to be opened by
+    ;; another Emacs process.
+    (cl-letf (((symbol-function #'ask-user-about-lock)
+               ;; FIXME: Emacs 27 does not yet have `always'.
+               (lambda (&rest _) t)))
+      (with-temp-file file
+        (insert ";;   -*- mode: lisp-data; -*-\n")
+        (if pp
+            (let ((pp-use-max-width nil)) ; Emacs bug#58687
+              (pp data (current-buffer)))
+          (prin1 data (current-buffer)))))
     (org-persist--display-time
      (- (float-time) start-time)
      "Writing to %S" file)))

Reply via email to