Hacker News new | ask | show | jobs
by hollerith 4200 days ago
>ad-hoc editing with sudo (precluding use of emacsclient)

It looks to me like you're probably unaware that an Emacs not running as root can edit files owned by root. The way it goes about it (in a word, TRAMP) is a little complicated under the hood, but (at least for files residing on the same machine as the Emacs process) reliable.

Specifically, both C-x C-f /sudo::/etc/hosts and `emacsclient /sudo::/etc/hosts` work.

1 comments

And you can have something fun like the following in your bashrc to allow attaching to your running emacs daemon any time you need in the terminal:

    function semacs() {
      emacsclient -t -a "" "/sudo::$(realpath $@)"
    }
Even more fun is using tramp to edit files as root on a machine via ssh. The whole installed editor canard is somewhat a nonissue from the emacs side.