Fix doom/sudo-save-buffer not writing changes

This commit is contained in:
Henrik Lissner 2020-04-14 19:12:52 -04:00
parent 2f380e8dd0
commit 61b3cd8818
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -358,9 +358,12 @@ file if it exists, without confirmation."
(let ((file (doom--sudo-file buffer-file-name)))
(if-let (buffer (find-file-noselect file))
(let ((origin (current-buffer)))
(copy-to-buffer buffer (point-min) (point-max))
(unwind-protect
(with-current-buffer buffer
(save-buffer))
(unless (eq origin buffer)
(kill-buffer buffer))))
(kill-buffer buffer))
(with-current-buffer origin
(revert-buffer t t))))
(user-error "Unable to open %S" file))))