[emacs] Add automatic open-as-root to ido-mode (from emacsredux.com)

This commit is contained in:
Correl Roush 2013-06-17 13:09:16 -04:00
parent c69b60408f
commit cbbb0327d6

View file

@ -102,6 +102,12 @@
(set-visited-file-name new-name)
(set-buffer-modified-p nil)))))))
(defadvice ido-find-file (after find-file-sudo activate)
"Find file as root if necessary."
(unless (and buffer-file-name
(file-writable-p buffer-file-name))
(find-alternate-file (concat "/sudo:root@localhost:" buffer-file-name))))
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.