Here's a way to open root file in a non-root run emacs:
erf () { SUDO_EDITOR="emacsclient -n -a emacs" sudoedit $@; } ;; erf = Emacs Root Foreground
It asks a root password, and once You enter it it opens a copy of file in /tmp
. Example:
$ cd /etc/apt
$ erf sources.list
opens: sourcesXXiOSmYN.list
. So I edit the thing, and save it with C-x C-s
-- but it's not saved:
$ sudoedit: sources.list unchanged
How do I make it save the thing? (the feature will be very neat)
Edit:
erf () { SUDO_EDITOR="emacsclient -a emacs" sudoedit $@; } ;; erf = Emacs Root Foreground
sovles it. Save a file and either -- kill the buffer or C-x #
. It works.