[comp.emacs] Setting load-path

dsill@NSWC-OAS.ARPA (Dave Sill) (11/09/88)

Why doesn't the following command work:
(setq load-path '("/local/dev/src/18.52/lisp" "/ef80/dsill/lib"))

It's in ~/.emacsrc, and I invoke Emacs as "emacs -l ~/.emacsrc".  The
rest of the commands in .emacsrc are executed, and if I manually load
.emacsrc everything seems to work right.

=========
"The current free flow of information will stop.  Everyone will be
very careful about who they come into contact with and with whom they
share their information.  [The computer virus plague] might do to
computers whats AIDS has done to sex."
				-- Anonymous Analyst in Datamation

mgkelley@bbn.com (Matthew G. Kelley) (11/09/88)

Dave Sill writes:
>Why doesn't the following command work:
>(setq load-path '("/local/dev/src/18.52/lisp" "/ef80/dsill/lib"))
>
>It's in ~/.emacsrc, and I invoke Emacs as "emacs -l ~/.emacsrc".  The
>rest of the commands in .emacsrc are executed, and if I manually load
>.emacsrc everything seems to work right.

I don't have an answer, but I have found similar behavior in a number
of other situations.  As one example, if I have the line:

(text-mode)

in my .emacs file, then when I start up Emacs, the initial buffer is in
initial-major-mode, not text-mode.  But, if I do a

M-x load-file .emacs

after I'm already in Emacs, then the buffer is put into text-mode as
expected.

Another point of interest is that the characteristic I want is in effect
_during_ the loading, but then reverts to the previous state after the
loading is finished. (I.e., the code in my .emacs file sees text-mode,
not initial-major-mode).

So, can anyone enlighten me as to the logic of all this (if there is any)?

choo@aqua.cs.yale.edu (young-il choo) (11/10/88)

In article <32024@bbn.COM> dsill@NSWC-OAS.ARPA (Dave Sill) writes:

   Why doesn't the following command work:
   (setq load-path '("/local/dev/src/18.52/lisp" "/ef80/dsill/lib"))

   It's in ~/.emacsrc, and I invoke Emacs as "emacs -l ~/.emacsrc".  The
   rest of the commands in .emacsrc are executed, and if I manually load
   .emacsrc everything seems to work right.

The answer is that it does work.

The problem is that after .emacsrc is loaded something else is reseting the
load-path -- most likely a locally defined file called "default.el"

If you look in ../lisp/starup.el at "command-line", when emacs starts, it
first processes all the command line arguments (including your -l
~/.emacsrc) and then it loads the user default ~/.emacs AND THEN it loads
default.el, UNLESS, you (setq inhibit-default-init t).

The solution is to (setq inhibit-default-init t), but check your
../local/default.el to see that nothing important is being ignored.

--  Young-il Choo  
-----------------  Yale Computer Science  --  choo-young-il@cs.yale.edu  --

mgkelley@bbn.com (Matthew G. Kelley) (11/10/88)

[Suggestion to use (setq inhibit-default-init t) to avoid having
load-path be reset after setting it in initialization.]

I think that a better solution is to use set-variable instead of setq:

(set-variable 'load-path <mumble>)

This works because (I think) the real problem is actually that the
symbol load-path is getting captured somewhere during the loading of
the initialization file, with something like:

(let ((load-path <mumble2>))
  (...
   (setq load-path <mumble>)))

When execution comes out of the let, the new value of load-path is
lost.  I'm sure this is what happens if a file is loaded with the -l
option, but I can't find it for the initialization file.

Matt

gildea@ALEXANDER.BBN.COM (Stephen Gildea) (11/22/88)

There are some initializations that are done after the .emacs file is
read.  These include terminal-dependent initializations and creating
the *scratch* buffer.  This is why the form (text-mode) seems to have
no effect in a .emacs file.  See the function command-line in
lisp/startup.el for details.

The original question, from Dave Sill, why setting load-path in a file
loaded with the -load command-line option doesn't work, seems to point
to a bug in Emacs.  During the loading of a file with -load, the
variable load-path is locally bound, thus any attempt to set it from
the loaded file will be undone as soon as the file is finished
loading.

 < Stephen