[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 484fc70a7ac: Fix "C-0 C-x C-s" with write-protected files
From: |
Eli Zaretskii |
Subject: |
master 484fc70a7ac: Fix "C-0 C-x C-s" with write-protected files |
Date: |
Mon, 16 Oct 2023 07:19:00 -0400 (EDT) |
branch: master
commit 484fc70a7acc5a958bfeefa4b83255680c7da175
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>
Fix "C-0 C-x C-s" with write-protected files
* lisp/files.el (basic-save-buffer-2): Call 'set-file-modes' to
try to make the file writable, even if
'set-file-extended-attributes' succeeded. (Bug#66546)
---
lisp/files.el | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/lisp/files.el b/lisp/files.el
index e1421b403bf..adfe8bd44b9 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -5933,9 +5933,10 @@ Before and after saving the buffer, this function runs
buffer-file-name)
t))
;; If file not writable, see if we can make it writable
- ;; temporarily while we write it.
- ;; But no need to do so if we have just backed it up
- ;; (setmodes is set) because that says we're superseding.
+ ;; temporarily while we write it (its original modes will be
+ ;; restored in 'basic-save-buffer'). But no need to do so if
+ ;; we have just backed it up (setmodes is set) because that
+ ;; says we're superseding.
(cond ((and tempsetmodes (not setmodes))
;; Change the mode back, after writing.
(setq setmodes
@@ -5944,12 +5945,12 @@ Before and after saving the buffer, this function runs
"Error getting extended attributes: %s"
(file-extended-attributes buffer-file-name))
buffer-file-name))
- ;; If set-file-extended-attributes fails, fall back on
- ;; set-file-modes.
- (unless
- (with-demoted-errors "Error setting attributes: %s"
- (set-file-extended-attributes buffer-file-name
- (nth 1 setmodes)))
+ ;; If set-file-extended-attributes fails to make the
+ ;; file writable, fall back on set-file-modes.
+ (with-demoted-errors "Error setting attributes: %s"
+ (set-file-extended-attributes buffer-file-name
+ (nth 1 setmodes)))
+ (unless (file-writable-p buffer-file-name)
(set-file-modes buffer-file-name
(logior (car setmodes) 128)))))
(let (success)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 484fc70a7ac: Fix "C-0 C-x C-s" with write-protected files,
Eli Zaretskii <=