Change how the "re-open file as root" functionality works
Fixes #850 Use find-file-hook instead of advising ido-find-file.
This commit is contained in:
parent
61d45f8e6e
commit
cd9ea1edee
1 changed files with 2 additions and 1 deletions
|
@ -302,13 +302,14 @@ buffer is not visiting a file."
|
||||||
(ido-read-file-name "Find file(as root): ")))
|
(ido-read-file-name "Find file(as root): ")))
|
||||||
(prelude-find-alternate-file-as-root buffer-file-name)))
|
(prelude-find-alternate-file-as-root buffer-file-name)))
|
||||||
|
|
||||||
(defadvice ido-find-file (after find-file-sudo activate)
|
(defun prelude-reopen-as-root ()
|
||||||
"Find file as root if necessary."
|
"Find file as root if necessary."
|
||||||
(unless (or (tramp-tramp-file-p buffer-file-name)
|
(unless (or (tramp-tramp-file-p buffer-file-name)
|
||||||
(equal major-mode 'dired-mode)
|
(equal major-mode 'dired-mode)
|
||||||
(not (file-exists-p (file-name-directory buffer-file-name)))
|
(not (file-exists-p (file-name-directory buffer-file-name)))
|
||||||
(file-writable-p buffer-file-name))
|
(file-writable-p buffer-file-name))
|
||||||
(prelude-find-alternate-file-as-root buffer-file-name)))
|
(prelude-find-alternate-file-as-root buffer-file-name)))
|
||||||
|
(add-hook 'find-file-hook 'prelude-reopen-as-root)
|
||||||
|
|
||||||
(defun prelude-start-or-switch-to (function buffer-name)
|
(defun prelude-start-or-switch-to (function buffer-name)
|
||||||
"Invoke FUNCTION if there is no buffer with BUFFER-NAME.
|
"Invoke FUNCTION if there is no buffer with BUFFER-NAME.
|
||||||
|
|
Loading…
Reference in a new issue