help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "variable [in .emacs] is void"


From: Kevin Rodgers
Subject: Re: "variable [in .emacs] is void"
Date: Tue, 23 Dec 2003 10:39:37 -0700
User-agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:0.9.4.1) Gecko/20020406 Netscape6/6.2.2

address@hidden wrote:

; first-try... didn't work
= (eval-after-load "sendmail"
=   (load "privhooks"))

For some reason this first try didn't work.  But specifying the entire
name and path did-- ungefaehr:

;second-try... worked
(eval-after-load "sendmail"
   (load "~/privhooks.el"))

The "load" function, according to the docs, searches the loadpath, not
my home directory. So that part of the failure is understandable. Then I thought that in the event I later compile privhooks.el, I want
the normal emacs behavior: first look for an *.elc and if that's not
found, then use the *.el.  So I tried:

;third-try... didn't work
(eval-after-load "sendmail"
   (load "~/privhooks"))

But this didn't work either.  So I went back to the full filespec.  But
being the fastidious sort, I'd like to make "~/privhooks" work.
The "load" doc says (in part):

(load FILE &optional NOERROR NOMESSAGE NOSUFFIX MUST-SUFFIX)

If optional fourth arg NOSUFFIX is non-nil, don't try adding
 suffixes `.elc' or `.el' to the specified name FILE.
If optional fifth arg MUST-SUFFIX is non-nil, insist on
 the suffix `.elc' or `.el'; don't accept just FILE unless
 it ends in one of those suffixes or includes a directory name.

I would think that load's default behavior would make third-try workable. But testing shows this isn't the case. So then I must specify the arg to accomplish this-- I'm guessing something like this:

;fourth try, guessing syntax for five args: all Messaging on. (eval-after-load "sendmail"
   '(load "~/privhooks" nil nil nil t))


It would be a lot easier to add your home directory to load-path, and then
call (load-library "privhooks").


Nope. The world still sucks. But hang on... dance around the cauldron one more time... toss in that eye of newt.

;fifth try, guessing syntax again.  Works!
(eval-after-load "sendmail"
   (load "~/privhooks" nil nil nil t))

Note the lack of a quote beginning the second line.


That does not do what you want it to.  You want your privhooks.el[c]
file to be automatically loaded after the sendmail library is loaded.
But by removing the quote, the form is evaluated immediately (i.e. when
.emacs is loaded, which is when emacs is invoked) rather than later.
The load form returns t (assuming your privhooks.el[c] file is found and
has no errors); so when the sendmail library is loaded, t is evaluated
(trivially returning t, with no side effects).


Two other things tell me this works, two lines which appear in
*Messages*:

Loading ~/.privhooks (source)...
Error in init file: Symbol's value as variable is void: mail-mode-map

The first line appears approximately whenever the syntax has been
without the quote.  (And actually I tried a lot more than what I've
written here.)  The second line confirms that the file is being loaded
because "mail-mode-map" only occurs in this file.  (Now to figure out
why that part isn't working... again.)

The first message is due to the fact that loading your .emacs file causes
your privhooks.el[c] file to be loaded, as explained above.  The second
message is due to the fact your privhooks.el file references mail-mode-map
in a form that is evaluated when the file is loaded, rather than when the
hook function defined in the file is actually run.

--
Kevin Rodgers



reply via email to

[Prev in Thread] Current Thread [Next in Thread]