help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: emacsclient and sudo


From: Jean Louis
Subject: Re: emacsclient and sudo
Date: Tue, 9 Mar 2021 09:04:52 +0300
User-agent: Mutt/2.0 (3d08634) (2020-11-07)

* Luca Ferrari <fluca1978@gmail.com> [2021-03-08 18:36]:
> On Wed, Feb 24, 2021 at 6:48 PM Luca Ferrari <fluca1978@gmail.com> wrote:
> >
> > So far, I'm starting it normally (without sudo) and use tramp to edit
> > a file with sudo, but sometimes my fingers are faster than my brain
> > and I type "sudo emacs ...".
> 
> Another solution I found is to export SUDO_EDITOR variable set to
> emacsclient and then use `sudo -e` to edit a file. While this works
> with regard to emacsclient, it does prevent emacs to load my .emacs
> configuration file.
> 
> % export SUDO_EDITOR="emacsclient -t -a ''"
> % sudo -e /etc/fstab
> 
> I would like to be able to use my customizations, any idea?

I just think that sudo will use $HOME as /root so one way could be to
provide HOME as your own one.

maybe like this:

export SUDO_EDITOR="env HOME=/home/myusername EDITOR"

but if you are using emacsclient that implies you wish to have server
running, so in that case server has to be started. As I have started
server as me, as user, this works just fine:

export SUDO_EDITOR="emacsclient -t -a ''"

on my side.

And this works as well good:

export SUDO_EDITOR="emacs -nw"

But if I would be user joe who wish to user HOME configuration of user
john, then I would be doing something like:

export SUDO_EDITOR="env HOME=/home/john emacs -nw"

provided that configuration is readable.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]