summary refs log tree commit diff stats
path: root/tag-emacs/emacs.d/init.org
diff options
context:
space:
mode:
authorAlan Pearce2015-10-16 11:25:11 +0200
committerAlan Pearce2015-10-16 11:25:11 +0200
commit4eb68236f9bd69752e609789bd22564a573683b3 (patch)
tree7e090a4037958a09170679b64fb895e407ba3296 /tag-emacs/emacs.d/init.org
parent88b381faace9ac226e340cc4db8fba6dd329b9a7 (diff)
downloadnixfiles-4eb68236f9bd69752e609789bd22564a573683b3.tar.lz
nixfiles-4eb68236f9bd69752e609789bd22564a573683b3.tar.zst
nixfiles-4eb68236f9bd69752e609789bd22564a573683b3.zip
Emacs: Re-add find-file-as-root advice for counsel
Diffstat (limited to 'tag-emacs/emacs.d/init.org')
-rw-r--r--tag-emacs/emacs.d/init.org5
1 files changed, 5 insertions, 0 deletions
diff --git a/tag-emacs/emacs.d/init.org b/tag-emacs/emacs.d/init.org
index 008b5b16..dd19554a 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")