fix(lib): sudo-{find,this}-file: disable auto-save
auto-save can trigger processes that hang silently in the background, making those buffers inoperable (hanging Emacs) for the rest of the session, even if they are killed (tramp caches them), so I suppress them solely for these temporary tramp buffers created by doom/sudo-find-file and doom/sudo-this-file.
This commit is contained in:
parent
4a9c71f96e
commit
d792f0dbb1
1 changed files with 14 additions and 8 deletions
|
@ -487,19 +487,25 @@ If FORCE-P, overwrite the destination file if it exists, without confirmation."
|
||||||
(defun doom/sudo-find-file (file)
|
(defun doom/sudo-find-file (file)
|
||||||
"Open FILE as root."
|
"Open FILE as root."
|
||||||
(interactive "FOpen file as root: ")
|
(interactive "FOpen file as root: ")
|
||||||
(find-file (doom--sudo-file-path (expand-file-name file))))
|
;; HACK: Disable auto-save in temporary tramp buffers because it could trigger
|
||||||
|
;; processes that hang silently in the background, making those buffers
|
||||||
|
;; inoperable for the rest of that session (Tramp caches them).
|
||||||
|
(let ((auto-save-default nil)
|
||||||
|
;; REVIEW: use only these when we drop 28 support
|
||||||
|
(remote-file-name-inhibit-auto-save t)
|
||||||
|
(remote-file-name-inhibit-auto-save-visited t))
|
||||||
|
(find-file (doom--sudo-file-path (expand-file-name file)))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom/sudo-this-file ()
|
(defun doom/sudo-this-file ()
|
||||||
"Open the current file as root."
|
"Open the current file as root."
|
||||||
(interactive)
|
(interactive)
|
||||||
(find-file
|
(doom/sudo-find-file
|
||||||
(doom--sudo-file-path
|
(or (buffer-file-name (buffer-base-buffer))
|
||||||
(or (buffer-file-name (buffer-base-buffer))
|
(when (or (derived-mode-p 'dired-mode)
|
||||||
(when (or (derived-mode-p 'dired-mode)
|
(derived-mode-p 'wdired-mode))
|
||||||
(derived-mode-p 'wdired-mode))
|
default-directory)
|
||||||
default-directory)
|
(user-error "Cannot determine the file path of the current buffer"))))
|
||||||
(user-error "Cannot determine the file path of the current buffer")))))
|
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom/sudo-save-buffer ()
|
(defun doom/sudo-save-buffer ()
|
||||||
|
|
Loading…
Reference in a new issue