From cbbb0327d6230de3eb61bf5752e5387794ddfe05 Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Mon, 17 Jun 2013 13:09:16 -0400 Subject: [PATCH] [emacs] Add automatic open-as-root to ido-mode (from emacsredux.com) --- .emacs.d/init.el | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 2162c58..6d0c91a 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -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.