From 4f018fb03b873f649eafeed16186fd791b55a1a8 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Fri, 3 Apr 2015 16:19:47 +0100 Subject: Emacs: Open files via sudo if needed --- tag-emacs/emacs.d/init.el | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tag-emacs/emacs.d/init.el b/tag-emacs/emacs.d/init.el index b7a16ae..c1b2c41 100644 --- a/tag-emacs/emacs.d/init.el +++ b/tag-emacs/emacs.d/init.el @@ -607,6 +607,11 @@ ido-enable-flex-matching t) (ido-init-completion-maps) + (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::" buffer-file-name)))) (defun ido-manual-merge () (interactive) (ido-initiate-auto-merge (current-buffer))) -- cgit 1.4.1