[comp.emacs] How do I abort processing of .emacs?

randy@garnet.UUCP (Randy Orrison) (01/11/89)

I'm a little annoyed with the behavior of GNU emacs when I'm su'ed to
root.  It reads my .emacs file (~randy/.emacs) instead of /.emacs,
which isn't too bad, though I'd prefer it read /.emacs.  In my .emacs,
though, I have a backup package which I got from someone on the net
(Neil Gordon Smithline <neil%buffalo.csnet@relay.cs.net>) which puts
all the backups in ~/.gnubackups.  For this, emacs expands ~ as /, but
I don't have a /.gnubackups directory, and don't want one.  I'd like
to not load the backups stuff when su'ed.  So, here's what I want to
do:

(if (equal (getenv "HOME") "/")
    ( skip-the-rest-of-.emacs ))

How do I do the skip?  (Or, is there a better way to do what I want?)

	Thanks!!!
		-randy

(P.S.  someday I'm going to read the elisp programming manual and
write a function that re-formats quoted paragraphs, keeping the '> '
at the beginning of each line, unless someone else has already done
this...  hint hint)

nate@hobbes.intel.com (Nate Hess) (01/12/89)

In article <103@garnet.UUCP>, randy@garnet (Randy Orrison) writes:
>I'm a little annoyed with the behavior of GNU emacs when I'm su'ed to
>root.  It reads my .emacs file (~randy/.emacs) instead of /.emacs,
>which isn't too bad, though I'd prefer it read /.emacs.

>I'd like to not load the backups stuff when su'ed.  So, here's what I
>want to do:

>(if (equal (getenv "HOME") "/")
>    ( skip-the-rest-of-.emacs ))

>How do I do the skip?  (Or, is there a better way to do what I want?)

What you might want to try is the function 'user-uid', which is
documented as follows:

user-uid:
Return the effective uid of Emacs, as an integer.

This suggests that you might want to try something like:

(if (> (user-uid) 0)
   (progn
     <rest of your .emacs>))

>(P.S.  someday I'm going to read the elisp programming manual and
>write a function that re-formats quoted paragraphs, keeping the '> '
>at the beginning of each line, unless someone else has already done
>this...  hint hint)

This has already been done.  Go check out Gnews 2.0.  It's an awesome
newsreader, as well as a place to scarf some useful Elisp from.

Happy Emacsing,
--woodstock
--
	   "What I like is when you're looking and thinking and looking
	   and thinking...and suddenly you wake up."   - Hobbes

woodstock@hobbes.intel.com   ...!{decwrl|hplabs!oliveb|amd}!intelca!mipos3!nate 

m1edb00@fed.frb.gov (Eric D. Boutilier) (01/13/89)

In article <103@garnet.UUCP>, randy@garnet (Randy Orrison) writes:
>I'm a little annoyed with the behavior of GNU emacs when I'm su'ed to
>root.  It reads my .emacs file (~randy/.emacs) instead of /.emacs,....

Emacs on our Suns can be invoked with a -u <username> flag
which means initialize with <username>'s .emacs file... so
maybe you can force it to use root's .emacs with:
	emacs -u root

On our system I su'ed to root and emacs used root's .emacs. I
think the problem might be with your su rather than emacs.

--------------
Eric Boutilier               UUCP: uunet!fed!eric
(202) 452-2734           INTERNET: eric@fed.frb.gov
                        ...or try: uunet!eric@uunet.uu.net

biesack@xyzzy.UUCP (Dave Biesack) (01/14/89)

In article <103@garnet.UUCP> randy@garnet.UUCP (Randy Orrison) writes:
> (if (equal (getenv "HOME") "/")
>     ( skip-the-rest-of-.emacs ))
> 
> How do I do the skip?  (Or, is there a better way to do what I want?)

One solution is to put any non-definition expressions of your .emacs
into a function, then your test can call that function under the 
circumstances you wish. For example,

(defun init-emacs ()
  ( rest-of-.emacs ))

Then, at the bottom of your .emacs, you have:

(or (equal (getenv "HOME") "/") (init-emacs))

This has an advantage that the function init-emacs can be byte compiled,
whereas top-level forms not in functions can't (last time i checked.)
So, your .emacs file can be loaded much faster. 

Another option, if your .emacs is very large and you don't want
emacs to spend time loading it when you login as root, is to
put most of it in another file, emacs.el, and have the .emacs
file load emacs.el[c] only under the conditions you specify.

> 
> 	Thanks!!!
> 		-randy
> 
> (P.S.  someday I'm going to read the elisp programming manual and
> write a function that re-formats quoted paragraphs, keeping the '> '
> at the beginning of each line, unless someone else has already done
> this...  hint hint)
> 


try "C-x .":
set-fill-prefix:
Set the fill-prefix to the current line up to point.
Filling expects lines to start with the fill prefix
and reinserts the fill prefix in each resulting line.

If you put the cursor at the '(' on the line beginning "> (P.S"
and execute set-fill-prefix, you can justify the paragraph. Is
this what you mean? For example, with fill-column equal to 78,
I executed fill-paragraph on your P.S. to get:

> (P.S.  someday I'm going to read the elisp programming manual and write a
> function that re-formats quoted paragraphs, keeping the '> ' at the
> beginning of each line, unless someone else has already done this...  hint
> hint)

djb

-- 
David J. Biesack  			Data General
{seismo, ...}!mcnc!rti!dg-rtp!biesack	Research Triangle Park, NC
biesack@dg-rtp.dg.com			(919) 248-5989

dch@cci632.UUCP (David C. Howland) (01/18/89)

In article <103@garnet.UUCP> randy@garnet.UUCP (Randy Orrison) writes:
(Done the indented-text-mode and set-fill-prefix.)
>
>(P.S.  someday I'm going to read the elisp programming manual and write
>a function that re-formats  quoted paragraphs, keeping  the '> ' at the
>beginning of  each line, unless  someone else has  already done this...
>hint hint)

Try indented-text-mode and set-fill-prefix. Isn't emacs great :-).

Indented Text Mode:
Major mode for editing indented text intended for humans to read.

set-fill-prefix:
Set the fill-prefix to the current line up to point.
Filling expects lines to start with the fill prefix
and reinserts the fill prefix in each resulting line.


	...once you have had EMACS, you'll NEVER go back!!


	dch@ccird3	- David C. Howland

jbw@bucsb.UUCP (Joe Wells) (01/18/89)

In article <2824@xyzzy.UUCP> biesack@dg-rtp.UUCP () writes:
>In article <103@garnet.UUCP> randy@garnet.UUCP (Randy Orrison) writes:
>> (if (equal (getenv "HOME") "/")
>>     ( skip-the-rest-of-.emacs ))
>> 
>> How do I do the skip?  (Or, is there a better way to do what I want?)

Actually, there is a way to do what you want.  However it's really ugly.

(defun eat-up-input ()
  "Will read and discard all characters in the current stdio input
stream.  This of course, should only be called when such a stream
exists, ie., inside of a load."
  (condition-case ()
      (while (read nil))
    (end-of-file nil)))

This has the problem that it is really slow, and the only reason that
I wanted to use it was to speed up loading my .emacs file undercertain
circumstances, e.g., a slow VAX.

So, you could do this:

(if (equal (getenv "HOME") "/") (eat-up-input))

--
Joe Wells		INTERNET: jbw%bucsf.bu.edu@bu-it.bu.edu
UUCP: ...!harvard!bu-cs!bucsf!jbw	      IP: [128.197.2.9]