From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kevin Rodgers Newsgroups: gmane.emacs.help Subject: Re: Interesting problem: eval-after-load and local variables Date: Tue, 16 Oct 2012 21:23:56 -0600 Message-ID: References: <80y5j6etfl.fsf@somewhere.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1350444240 24128 80.91.229.3 (17 Oct 2012 03:24:00 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 17 Oct 2012 03:24:00 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Oct 17 05:24:07 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TOKEn-0001bH-Cu for geh-help-gnu-emacs@m.gmane.org; Wed, 17 Oct 2012 05:24:05 +0200 Original-Received: from localhost ([::1]:42498 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOKEg-0003XD-D2 for geh-help-gnu-emacs@m.gmane.org; Tue, 16 Oct 2012 23:23:58 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:35226) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOKEa-0003Wx-PZ for help-gnu-emacs@gnu.org; Tue, 16 Oct 2012 23:23:53 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TOKEZ-0005Mq-Hg for help-gnu-emacs@gnu.org; Tue, 16 Oct 2012 23:23:52 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:52399) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOKEZ-0005Mm-At for help-gnu-emacs@gnu.org; Tue, 16 Oct 2012 23:23:51 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1TOKEc-0001OY-PF for help-gnu-emacs@gnu.org; Wed, 17 Oct 2012 05:23:54 +0200 Original-Received: from c-71-237-25-24.hsd1.co.comcast.net ([71.237.25.24]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 17 Oct 2012 05:23:54 +0200 Original-Received: from kevin.d.rodgers by c-71-237-25-24.hsd1.co.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 17 Oct 2012 05:23:54 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 83 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: c-71-237-25-24.hsd1.co.comcast.net User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9.2.28) Gecko/20120306 Thunderbird/3.1.20 In-Reply-To: <80y5j6etfl.fsf@somewhere.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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 Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:87298 Archived-At: On 10/16/12 2:02 AM, Sebastien Vauban wrote: > In order to speed up my Emacs startup, I've put many customizations in > eval-after-load's, such as: > > --8<---------------cut here---------------start------------->8--- > (eval-after-load "time-stamp" > '(progn > ;; format of the string inserted by `M-x time-stamp' > (setq time-stamp-format "%:y-%02m-%02d %3a %02H:%02M %u"))) > --8<---------------cut here---------------end--------------->8--- > > in order to avoid the require itself in the .emacs file. In general, it is not necessary to load a library before customizing its global options. You should get the desired effect with just: (setq time-stamp-format "%:y-%02m-%02d %3a %02H:%02M %u") > Now, this causes a problem, as my local variable customizations aren't > respected anymore. > > For example, I have the following local vars in my file `common.sty' to set up > the format of the time-stamp (à la LaTeX): > > --8<---------------cut here---------------start------------->8--- > %% common.sty -- LaTeX common commands and environments > > \NeedsTeXFormat{LaTeX2e} > \ProvidesPackage{common}[2012/10/15 v1.0 Common stuff between documents and presentations] > > % ... > > %% End of package > \endinput % very last line > > % Local Variables: > % time-stamp-format: "%:y/%02m/%02d" > % time-stamp-start: "Provides\\(Class\\|Package\\){[a-zA-Z-]+}\\[" > % time-stamp-end: " " > % End: > --8<---------------cut here---------------end--------------->8--- > > The problem is the following: > > - Upon opening the file, Emacs sees it needs to load time-stamp. I don't see how, since those variables aren't autoloaded. (Their autoload cookies only result in the safe-local-variable property being dumped into the emacs executable for each symbol.) I suspect you have enabled time stamp as documented in the Emacs manual: Then add the hook function `time-stamp' to the hook `before-save-hook'; that hook function will automatically update the time stamp, inserting the current date and time when you save the file. (The function time-stamp is autoloaded.) > - It does it (via the predefined autoloads), but the eval-after-load overrides > the local variables' value. Yes, because the eval-after-load form is apparently evaluated while the common.sty buffer is current, and the file local variable section has already made each variable local to that buffer. > - When saving the file, the time-stamp format provided in local vars is NOT > applied. Actually, I think the file local variables are applied and then overridden by the eval-after-load form (but only for the first file that you save). Do other files with time stamp templates work as intended? > In a way, that's perfectly normal. In another, not at all: I would expect the > local vars to win over the wide values, in any configuration (even if my setq > were in an eval-after-load construct). > > What do you think? I think you should either skip the eval-after-load boilerplate, or use setq-default in the eval-after-load form as suggested by Michael. -- Kevin Rodgers Denver, Colorado, USA