目前我是这样用 sudo 来临时提权保存,但是原文件的权限信息会丢失,导致普通用户之后也能修改了
(save-restriction
(widen)
(let ((tmp (make-temp-file "emacs-" nil nil (buffer-string))))
(call-process "sudo" nil nil nil "move"
(subst-char-in-string ?/ ?\\ tmp) (buffer-file-name))))
(set-buffer-modified-p nil)