Skip to content

Instantly share code, notes, and snippets.

@smonff smonff/.emacs
Created Sep 7, 2014

What would you like to do?
Gain sudo privileges in Emacs without launch it as sudo
;; Makes possible to sudo-edit files
;; From Damien Cassou
(defun sudo ()
(let ((fname (or buffer-file-name
(when fname
(if (string-match "^/sudo:root@localhost:" fname)
(setq fname (replace-regexp-in-string
"^/sudo:root@localhost:" ""
(setq fname (concat "/sudo:root@localhost:" fname)))
(find-alternate-file fname))))

This comment has been minimized.

Copy link
Owner Author

commented Sep 7, 2014

To use from dired-mode, type M-x sudo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.