From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Harry Putnam Newsgroups: gmane.emacs.help Subject: Re: Customising .init.el for root user Date: Fri, 21 Jun 2013 15:49:36 -0400 Organization: Still searching... Message-ID: <8761x7qm5r.fsf@newsguy.com> References: <871u7woijw.fsf@gmx.co.uk> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1371844285 31008 80.91.229.3 (21 Jun 2013 19:51:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 21 Jun 2013 19:51:25 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jun 21 21:51:25 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Uq7Mi-0000NE-EL for geh-help-gnu-emacs@m.gmane.org; Fri, 21 Jun 2013 21:51:24 +0200 Original-Received: from localhost ([::1]:53614 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uq7Mi-0003bb-3t for geh-help-gnu-emacs@m.gmane.org; Fri, 21 Jun 2013 15:51:24 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46269) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uq7MW-0003WM-9q for help-gnu-emacs@gnu.org; Fri, 21 Jun 2013 15:51:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uq7MV-0001jc-3v for help-gnu-emacs@gnu.org; Fri, 21 Jun 2013 15:51:12 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:45547) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uq7MU-0001jT-Tg for help-gnu-emacs@gnu.org; Fri, 21 Jun 2013 15:51:11 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Uq7MU-00009e-8g for help-gnu-emacs@gnu.org; Fri, 21 Jun 2013 21:51:10 +0200 Original-Received: from z65-50-57-227.ips.direcpath.com ([65.50.57.227]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 21 Jun 2013 21:51:10 +0200 Original-Received: from reader by z65-50-57-227.ips.direcpath.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 21 Jun 2013 21:51:10 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 55 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: z65-50-57-227.ips.direcpath.com User-Agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.0.92 (gnu/linux) Cancel-Lock: sha1:2FtZ4Y5MOdK8390wa+7z8OP6F38= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:91655 Archived-At: Johnny writes: > Hi, > > Starting emacs as my normal user running a root terminal (via su), I want > emacs to start with some specific parameters that does not apply when > running as the normal user. Specifically, I want the color to be > distinct so that it is obvious which emacs is the root session. > > I understand that by default the users init file is used [1]. This > never worked well for me, defaulting into basic settings, but after > looking into it and replacing any "~" references with full paths, it > works as intended. > However, this gives /all/ the defaults in the user init file, such as > the color-theme used. I already use the same init file for multiple > (well, two anyhow) computers and use a check which machine I am on for > some dedicated settings, e.g. > ,---- > | (when (string= (system-name) "the other machine") > | ..run some customisations... > | ) > `---- > Is there any similar way to check whether the session was started with > root privileges to set customisations? E.g. > ,---- > | (when (session-started-as-root) > | (load-theme 'wheatgrass) > | ) > `---- > with a 'session-started-as-root' function? Better methods?? > > I found one way is to default to a root init file by defining an alias > in the root .bashrc as > ,---- > | alias emacs="emacs -u root" > `---- > however it would be nice to have only one init file to keep track of as > many tweaks are nice to have in all sessions. The old hands here will probably have much better ways, but I've found its just easier to put the code for the desired changes in a small *.el file in your path like for-root.el containing code to effect the changes you want for the root session. You do have to remember to load it manually unless you want the slicker ways. But I've found over time its just easier to keep up with the way I described above. Then when you start emacs as root just load that file with M-x load-library for-root Or perhaps create an aliase for emacs that loads the file like: alias emrt="emacs -l /path/to/for-root.el" And start emacs with `emrt' when running as root.