From 4eb68236f9bd69752e609789bd22564a573683b3 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Fri, 16 Oct 2015 11:25:11 +0200 Subject: Emacs: Re-add find-file-as-root advice for counsel --- tag-emacs/emacs.d/init.org | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tag-emacs') diff --git a/tag-emacs/emacs.d/init.org b/tag-emacs/emacs.d/init.org index 008b5b1..dd19554 100644 --- a/tag-emacs/emacs.d/init.org +++ b/tag-emacs/emacs.d/init.org @@ -1246,6 +1246,11 @@ replace helm and ido. ("C-x C-f" . counsel-find-file) ("C-x b" . counsel-switch-to-projectile-buffer)) :config (progn + (defadvice counsel-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 counsel-switch-to-projectile-buffer (arg) "Forward to `projectile-switch-to-buffer'." (interactive "P") -- cgit 1.4.1