diff --git a/lisp/lib/files.el b/lisp/lib/files.el index 94b47d4a3..8f03b4abe 100644 --- a/lisp/lib/files.el +++ b/lisp/lib/files.el @@ -487,19 +487,25 @@ If FORCE-P, overwrite the destination file if it exists, without confirmation." (defun doom/sudo-find-file (file) "Open 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 (defun doom/sudo-this-file () "Open the current file as root." (interactive) - (find-file - (doom--sudo-file-path - (or (buffer-file-name (buffer-base-buffer)) - (when (or (derived-mode-p 'dired-mode) - (derived-mode-p 'wdired-mode)) - default-directory) - (user-error "Cannot determine the file path of the current buffer"))))) + (doom/sudo-find-file + (or (buffer-file-name (buffer-base-buffer)) + (when (or (derived-mode-p 'dired-mode) + (derived-mode-p 'wdired-mode)) + default-directory) + (user-error "Cannot determine the file path of the current buffer")))) ;;;###autoload (defun doom/sudo-save-buffer ()