[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 89558533683: Don't signal error when locking a file from non file
|
From: |
Eli Zaretskii |
|
Subject: |
master 89558533683: Don't signal error when locking a file from non file-visiting buffer |
|
Date: |
Mon, 24 Jul 2023 11:10:11 -0400 (EDT) |
branch: master
commit 89558533683a100ca7946c4a35bf4ef50463efef
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>
Don't signal error when locking a file from non file-visiting buffer
* lisp/userlock.el (userlock--check-content-unchanged): Support
the case where a file is locked before being written to from a
non file-visiting buffer. (Bug#64821)
---
lisp/userlock.el | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/lisp/userlock.el b/lisp/userlock.el
index 562bc0a0a9f..96de17d54fd 100644
--- a/lisp/userlock.el
+++ b/lisp/userlock.el
@@ -110,10 +110,11 @@ You can <\\`q'>uit; don't modify this file."))
(defun userlock--check-content-unchanged (filename)
(with-demoted-errors "Unchanged content check: %S"
- ;; Even tho we receive `filename', we know that `filename' refers to the
current
- ;; buffer's file.
- (cl-assert (equal (expand-file-name filename)
- (expand-file-name buffer-file-truename)))
+ ;; Even tho we receive `filename', we know that `filename' refers
+ ;; to the current buffer's file.
+ (cl-assert (or (null buffer-file-truename) ; temporary buffer
+ (equal (expand-file-name filename)
+ (expand-file-name buffer-file-truename))))
;; Note: rather than read the file and compare to the buffer, we could save
;; the buffer and compare to the file, but for encrypted data this
;; wouldn't work well (and would risk exposing the data).
@@ -135,7 +136,13 @@ You can <\\`q'>uit; don't modify this file."))
(compare-buffer-substrings
buf start end
(current-buffer) (point-min) (point-max))))))
- (set-visited-file-modtime)
+ ;; We know that some buffer visits FILENAME, because our
+ ;; caller (see lock_file) verified that. Thus, we set the
+ ;; modtime in that buffer, to cater to use case where the
+ ;; file is about to be written to from some buffer that
+ ;; doesn't visit any file, like a temporary buffer.
+ (with-current-buffer (get-file-buffer (file-truename filename))
+ (set-visited-file-modtime))
'unchanged)))))
;;;###autoload
| [Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 89558533683: Don't signal error when locking a file from non file-visiting buffer,
Eli Zaretskii <=