unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [Fwd: Location of .emacs file under `su` and `su -`?]
@ 2006-08-22 12:12 Lennart Borgman
  2006-08-22 15:18 ` Chong Yidong
  0 siblings, 1 reply; 7+ messages in thread
From: Lennart Borgman @ 2006-08-22 12:12 UTC (permalink / raw)


How about this in Emacs 22?

-------- Original Message --------
Subject:     Location of .emacs file under `su` and `su -`?
Date:     Tue, 22 Aug 2006 12:26:27 +0100
From:     Adam Funk <a24061@yahoo.com>
To:     help-gnu-emacs@gnu.org
Newsgroups:     gnu.emacs.help


When I use `su` and run emacs, I get errors because it loads
~adam/.emacs as the init file, which contains 

  (add-to-list 'load-path "~/.local/site-lisp/")

but then doesn't find the *.el and *.elc files there, because (as far
as I can tell) it's looking in /root/.local/site-lisp/, which doesn't
exist.  Does that seem to be a correct interpretation?

When I use `su -` and run emacs, it loads ~root/.emacs as the init
file.

In both cases, `env` tells me
 
  EDITOR=/usr/bin/emacs
  HOME=/root
  USERNAME=root
  USER=root

so I think the difference is here:

  su      -->  LOGNAME=adam
  su -    -->  LOGNAME=root

When emacs starts up, does it actually look up "~${LOGNAME}/.emacs"
instead of (what I would expect) "${HOME}/.emacs"?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Fwd: Location of .emacs file under `su` and `su -`?]
  2006-08-22 12:12 [Fwd: Location of .emacs file under `su` and `su -`?] Lennart Borgman
@ 2006-08-22 15:18 ` Chong Yidong
  2006-08-22 15:42   ` Andreas Schwab
  2006-08-22 18:17   ` Richard Stallman
  0 siblings, 2 replies; 7+ messages in thread
From: Chong Yidong @ 2006-08-22 15:18 UTC (permalink / raw)
  Cc: Emacs Devel

Lennart Borgman <lennart.borgman.073@student.lu.se> writes:

> Subject:     Location of .emacs file under `su` and `su -`?
> From:     Adam Funk <a24061@yahoo.com>
>
> When I use `su` and run emacs, I get errors because it loads
> ~adam/.emacs as the init file, which contains 
>
>  (add-to-list 'load-path "~/.local/site-lisp/")
>
> but then doesn't find the *.el and *.elc files there
>
> When emacs starts up, does it actually look up "~${LOGNAME}/.emacs"
> instead of (what I would expect) "${HOME}/.emacs"?

Yes.  I'm not sure why.  This contradicts the information in the Emacs
manual, which says to use HOME.  Anyway, this is trivial to fix.  I'll
check the following patch in over the next few days if no one objects.

*** emacs/lisp/startup.el.~1.410.~	2006-07-24 00:18:47.000000000 -0400
--- emacs/lisp/startup.el	2006-08-22 11:14:56.000000000 -0400
***************
*** 865,871 ****
  			    ((eq system-type 'vax-vms)
  			     "sys$login:.emacs")
  			    (t
! 			     (concat "~" init-file-user "/.emacs")))))
  		      ;; This tells `load' to store the file name found
  		      ;; into user-init-file.
  		      (setq user-init-file t)
--- 865,871 ----
  			    ((eq system-type 'vax-vms)
  			     "sys$login:.emacs")
  			    (t
! 			     "~/.emacs"))))
  		      ;; This tells `load' to store the file name found
  		      ;; into user-init-file.
  		      (setq user-init-file t)
***************
*** 877,884 ****
  			(let ((otherfile
  			       (expand-file-name
  				"init"
! 				(file-name-as-directory
! 				 (concat "~" init-file-user "/.emacs.d")))))
  			  (load otherfile t t)
  
  			  ;; If we did not find the user's init file,
--- 877,883 ----
  			(let ((otherfile
  			       (expand-file-name
  				"init"
! 				(file-name-as-directory "~/.emacs.d"))))
  			  (load otherfile t t)
  
  			  ;; If we did not find the user's init file,

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Fwd: Location of .emacs file under `su` and `su -`?]
  2006-08-22 15:18 ` Chong Yidong
@ 2006-08-22 15:42   ` Andreas Schwab
  2006-08-22 18:17   ` Richard Stallman
  1 sibling, 0 replies; 7+ messages in thread
From: Andreas Schwab @ 2006-08-22 15:42 UTC (permalink / raw)
  Cc: Lennart Borgman, Emacs Devel

Chong Yidong <cyd@stupidchicken.com> writes:

> Yes.  I'm not sure why.  This contradicts the information in the Emacs
> manual, which says to use HOME.  Anyway, this is trivial to fix.  I'll
> check the following patch in over the next few days if no one objects.
>
> *** emacs/lisp/startup.el.~1.410.~	2006-07-24 00:18:47.000000000 -0400
> --- emacs/lisp/startup.el	2006-08-22 11:14:56.000000000 -0400
> ***************
> *** 865,871 ****
>   			    ((eq system-type 'vax-vms)
>   			     "sys$login:.emacs")
>   			    (t
> ! 			     (concat "~" init-file-user "/.emacs")))))
>   		      ;; This tells `load' to store the file name found
>   		      ;; into user-init-file.
>   		      (setq user-init-file t)
> --- 865,871 ----
>   			    ((eq system-type 'vax-vms)
>   			     "sys$login:.emacs")
>   			    (t
> ! 			     "~/.emacs"))))
>   		      ;; This tells `load' to store the file name found
>   		      ;; into user-init-file.

How does this preserve the functionality of `emacs --user foo'?

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Fwd: Location of .emacs file under `su` and `su -`?]
  2006-08-22 15:18 ` Chong Yidong
  2006-08-22 15:42   ` Andreas Schwab
@ 2006-08-22 18:17   ` Richard Stallman
  2006-08-22 18:44     ` Chong Yidong
  1 sibling, 1 reply; 7+ messages in thread
From: Richard Stallman @ 2006-08-22 18:17 UTC (permalink / raw)
  Cc: lennart.borgman.073, emacs-devel

				((eq system-type 'vax-vms)
				 "sys$login:.emacs")
				(t
    ! 			     "~/.emacs"))))

Don't install that change!
It would break the feature that emacs runs your
own init file (not root's init file) if you have su'd.

It would also break -u.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Fwd: Location of .emacs file under `su` and `su -`?]
  2006-08-22 18:17   ` Richard Stallman
@ 2006-08-22 18:44     ` Chong Yidong
  2006-08-23  4:06       ` Richard Stallman
  0 siblings, 1 reply; 7+ messages in thread
From: Chong Yidong @ 2006-08-22 18:44 UTC (permalink / raw)
  Cc: lennart.borgman.073, emacs-devel

Richard Stallman <rms@gnu.org> writes:

> 				((eq system-type 'vax-vms)
> 				 "sys$login:.emacs")
> 				(t
>     ! 			     "~/.emacs"))))
>
> Don't install that change!
> It would break the feature that emacs runs your
> own init file (not root's init file) if you have su'd.
>
> It would also break -u.

Yeah, it was ill-conceived.

What should we do?  Would it suffice to update the Emacs manual to say
that the init file is looked for in the home directory of $USER
instead of $HOME?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Fwd: Location of .emacs file under `su` and `su -`?]
  2006-08-22 18:44     ` Chong Yidong
@ 2006-08-23  4:06       ` Richard Stallman
  2006-08-23 16:38         ` Chong Yidong
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Stallman @ 2006-08-23  4:06 UTC (permalink / raw)
  Cc: lennart.borgman.073, emacs-devel

    What should we do?  Would it suffice to update the Emacs manual to say
    that the init file is looked for in the home directory of $USER
    instead of $HOME?

If you think the manual needs clarification, you're probably right.
However, isn't the node Find Init clear enough?

Perhaps the problem is that the node Init File makes a blanket statement
about using HOME, which in fact is true only in the usual case.
So that part could use rewriting.

Would you like to try it?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Fwd: Location of .emacs file under `su` and `su -`?]
  2006-08-23  4:06       ` Richard Stallman
@ 2006-08-23 16:38         ` Chong Yidong
  0 siblings, 0 replies; 7+ messages in thread
From: Chong Yidong @ 2006-08-23 16:38 UTC (permalink / raw)
  Cc: lennart.borgman.073, emacs-devel

Richard Stallman <rms@gnu.org> writes:

>     What should we do?  Would it suffice to update the Emacs manual to say
>     that the init file is looked for in the home directory of $USER
>     instead of $HOME?
>
> If you think the manual needs clarification, you're probably right.
> However, isn't the node Find Init clear enough?
>
> Perhaps the problem is that the node Init File makes a blanket statement
> about using HOME, which in fact is true only in the usual case.
> So that part could use rewriting.
>
> Would you like to try it?

I removed the blanket statement, and added an xref to Find Init.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-08-23 16:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-22 12:12 [Fwd: Location of .emacs file under `su` and `su -`?] Lennart Borgman
2006-08-22 15:18 ` Chong Yidong
2006-08-22 15:42   ` Andreas Schwab
2006-08-22 18:17   ` Richard Stallman
2006-08-22 18:44     ` Chong Yidong
2006-08-23  4:06       ` Richard Stallman
2006-08-23 16:38         ` Chong Yidong

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).