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

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

bug#66546: 30.0.50; save-buffer to write-protected file without backup f


From: Eli Zaretskii
Subject: bug#66546: 30.0.50; save-buffer to write-protected file without backup fails
Date: Fri, 20 Oct 2023 09:06:35 +0300

> From: Jens Schmidt <jschmidt4gnu@vodafonemail.de>
> Cc: 66546@debbugs.gnu.org
> Date: Thu, 19 Oct 2023 23:12:59 +0200
> 
> But probably it would be helpful to shortcut that look-up process, like
> this:
> 
> @@ -5946,7 +5949,9 @@ basic-save-buffer-2
>                              (file-extended-attributes buffer-file-name))
>                            buffer-file-name))
>                ;; If set-file-extended-attributes fails to make the
> -              ;; file writable, fall back on set-file-modes.
> +              ;; file writable, fall back on set-file-modes.  Calling
> +              ;; set-file-extended-attributes here may or may not be
> +              ;; actually necessary, for details see Bug#66546.
>                (with-demoted-errors "Error setting attributes: %s"
>                  (set-file-extended-attributes buffer-file-name
>                                                (nth 1 setmodes)))

I don't object, though a more detailed explanation (instead of sending
people to read the bug discussion) would be better.

> +             ;; If we get an error writing the file which we
> +             ;; previously made writable, attempt to undo the
> +             ;; write-access.
> +             ((and (eq tempsetmodes 'u+w) (not success))

Isn't it easier, safer, and more portable to compare buffer-file-name
with (nth 2 setmodes) instead?

> +              (condition-case ()
> +               (unless
> +                   (with-demoted-errors "Error setting file modes: %S"
> +                     (set-file-modes buffer-file-name (car setmodes)))
> +                 (set-file-extended-attributes buffer-file-name
> +                                               (nth 1 setmodes)))
> +             (error nil)))

Why do we need condition-case here if we use with-demoted-errors?

> I also attached a slightly unrelated, minor doc fix I came across
> when working on this bug.

Thanks, installed on the emacs-29 branch (with minor changes in the
commit log message).





reply via email to

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