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: Thu, 18 Oct 2012 06:55:36 -0600 Message-ID: References: <80y5j6etfl.fsf@somewhere.org> <808vb58pmw.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: 7bit X-Trace: ger.gmane.org 1350564950 7400 80.91.229.3 (18 Oct 2012 12:55:50 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 18 Oct 2012 12:55:50 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Oct 18 14:55:57 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 1TOpdl-0002Ag-89 for geh-help-gnu-emacs@m.gmane.org; Thu, 18 Oct 2012 14:55:57 +0200 Original-Received: from localhost ([::1]:56571 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOpde-0000oH-0M for geh-help-gnu-emacs@m.gmane.org; Thu, 18 Oct 2012 08:55:50 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:56689) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOpdX-0000gh-Hd for help-gnu-emacs@gnu.org; Thu, 18 Oct 2012 08:55:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TOpdU-0004UR-2s for help-gnu-emacs@gnu.org; Thu, 18 Oct 2012 08:55:43 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:50600) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOpdT-0004UI-SR for help-gnu-emacs@gnu.org; Thu, 18 Oct 2012 08:55:40 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1TOpdV-0001r0-WF for help-gnu-emacs@gnu.org; Thu, 18 Oct 2012 14:55:42 +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 ; Thu, 18 Oct 2012 14:55:41 +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 ; Thu, 18 Oct 2012 14:55:41 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 61 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: <808vb58pmw.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:87316 Archived-At: On 10/17/12 2:32 AM, Sebastien Vauban wrote: > Kevin Rodgers wrote: ... >> 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") > > I know. And this is a very somewhat ridiculous example. But, for speed and > clarity of my .emacs, I've generally put all customs inside an > eval-after-load. A setq is certainly not time-taker, certainly not when alone, > but I've applied the same principal to many other blocks of customs. I don't see how the eval-after-load boilerplate provides any speed or clarity. ... >> 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.) > > You're absolutely right! I described the correct effect, but not the right > cause... ... >> 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). > > Your explanation must be right. But my question was more general, in the > sense: is this the behavior one would expect? Or *should local vars triumph > over the setq done in the eval-after-load?* We should expect file local variables and eval-after-load to work as documented -- and they do. It is our responsibility to use them correctly -- but you used eval-after-load unnecessarily, without considering the context. >> Do other files with time stamp templates work as intended? > > I'll check (but I've already applied the fix suggested by Michael). I guess > the answer is yes. ... >> I think you should either skip the eval-after-load boilerplate > > As said, for this example: you're definitively right. It's kind of useless. > >> or use setq-default in the eval-after-load form as suggested by Michael. > > Can I use setq-default with whichever var? I guess not. But am I right? You _can_ use setq-default on any variable, to ensure that you are setting its global binding and not the current buffer-local binding (if any). -- Kevin Rodgers Denver, Colorado, USA