From 2f22cb268400cd2b54fd06dfee44f2e77187c4f2 Mon Sep 17 00:00:00 2001 From: toctan Date: Wed, 30 Jul 2014 20:04:38 +0800 Subject: [PATCH] Fix editing remote unwriteable file With the original advice, if we try to find a not writeable file on a remote machine, the extra tramp prefix would be inserted. As a result, we actually end up in a blank new file. --- core/prelude-core.el | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/core/prelude-core.el b/core/prelude-core.el index 12d15d0..8716521 100644 --- a/core/prelude-core.el +++ b/core/prelude-core.el @@ -303,11 +303,10 @@ buffer is not visiting a file." (defadvice ido-find-file (after find-file-sudo activate) "Find file as root if necessary." - (unless (or (equal major-mode 'dired-mode) - (and (buffer-file-name) - (not (file-exists-p (file-name-directory (buffer-file-name))))) - (and (buffer-file-name) - (file-writable-p buffer-file-name))) + (unless (or (tramp-tramp-file-p buffer-file-name) + (equal major-mode 'dired-mode) + (not (file-exists-p (file-name-directory buffer-file-name))) + (file-writable-p buffer-file-name)) (find-alternate-file (concat "/sudo:root@localhost:" buffer-file-name)))) (defun prelude-start-or-switch-to (function buffer-name)