From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.help Subject: Re: emacsclient and sudo Date: Tue, 9 Mar 2021 09:04:52 +0300 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6218"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/2.0 (3d08634) (2020-11-07) Cc: help-gnu-emacs To: Luca Ferrari Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Mar 09 07:10:40 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lJVZo-0001VE-Jr for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 09 Mar 2021 07:10:40 +0100 Original-Received: from localhost ([::1]:44906 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJVZn-0006rZ-Mq for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 09 Mar 2021 01:10:39 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49720) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJVYv-0006rO-Ph for help-gnu-emacs@gnu.org; Tue, 09 Mar 2021 01:09:45 -0500 Original-Received: from stw1.rcdrun.com ([217.170.207.13]:52561) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJVYs-0000uS-Jc for help-gnu-emacs@gnu.org; Tue, 09 Mar 2021 01:09:45 -0500 Original-Received: from localhost ([::ffff:41.210.154.208]) (AUTH: PLAIN securesender, TLS: TLS1.2,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 000000000001E1CD.0000000060471103.000069E6; Mon, 08 Mar 2021 23:09:06 -0700 Mail-Followup-To: Luca Ferrari , help-gnu-emacs Content-Disposition: inline In-Reply-To: Received-SPF: pass client-ip=217.170.207.13; envelope-from=bugs@gnu.support; helo=stw1.rcdrun.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:128371 Archived-At: * Luca Ferrari [2021-03-08 18:36]: > On Wed, Feb 24, 2021 at 6:48 PM Luca Ferrari 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.