Created
September 7, 2014 19:10
-
-
Save smonff/09d41b2a0fe8d0200583 to your computer and use it in GitHub Desktop.
Gain sudo privileges in Emacs without launch it as sudo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Makes possible to sudo-edit files | |
;; From Damien Cassou | |
;; https://github.com/renard/dired-toggle-sudo/issues/1 | |
(defun sudo () | |
(interactive) | |
(let ((fname (or buffer-file-name | |
dired-directory))) | |
(when fname | |
(if (string-match "^/sudo:root@localhost:" fname) | |
(setq fname (replace-regexp-in-string | |
"^/sudo:root@localhost:" "" | |
fname)) | |
(setq fname (concat "/sudo:root@localhost:" fname))) | |
(find-alternate-file fname)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To use from
dired-mode
, typeM-x sudo