From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Kevin Rodgers Newsgroups: gmane.emacs.help Subject: Re: "variable [in .emacs] is void" Date: Tue, 23 Dec 2003 10:39:37 -0700 Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <3FE87DD9.2070508@yahoo.com> References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1072201509 16123 80.91.224.253 (23 Dec 2003 17:45:09 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 23 Dec 2003 17:45:09 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Dec 23 18:45:01 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AYqab-0002gY-00 for ; Tue, 23 Dec 2003 18:45:01 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AYrXg-0004Eb-M4 for geh-help-gnu-emacs@m.gmane.org; Tue, 23 Dec 2003 13:46:04 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!bloom-beacon.mit.edu!npeer.de.kpn-eurorings.net!fu-berlin.de!uni-berlin.de!170.207.51.80!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 89 Original-NNTP-Posting-Host: 170.207.51.80 Original-X-Trace: news.uni-berlin.de 1072201179 11643789 170.207.51.80 ([82742]) User-Agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:0.9.4.1) Gecko/20020406 Netscape6/6.2.2 X-Accept-Language: en-us Original-Xref: shelby.stanford.edu gnu.emacs.help:119602 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 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 Xref: main.gmane.org gmane.emacs.help:15542 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:15542 gebser@speakeasy.net 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