From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.help Subject: Re: Interesting problem: eval-after-load and local variables Date: Thu, 18 Oct 2012 06:09:10 +0200 Message-ID: <87y5j4wheh.fsf@web.de> References: <80y5j6etfl.fsf@somewhere.org> <808vb58pmw.fsf@somewhere.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1350533346 10030 80.91.229.3 (18 Oct 2012 04:09:06 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 18 Oct 2012 04:09:06 +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 06:09:14 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 1TOhQ1-00068c-UC for geh-help-gnu-emacs@m.gmane.org; Thu, 18 Oct 2012 06:09:14 +0200 Original-Received: from localhost ([::1]:58634 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOhPu-00020Y-MQ for geh-help-gnu-emacs@m.gmane.org; Thu, 18 Oct 2012 00:09:06 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:38281) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOhPo-00020D-Qm for help-gnu-emacs@gnu.org; Thu, 18 Oct 2012 00:09:01 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TOhPn-0000bm-QR for help-gnu-emacs@gnu.org; Thu, 18 Oct 2012 00:09:00 -0400 Original-Received: from mout.web.de ([212.227.17.11]:61985) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOhPn-0000bd-H5 for help-gnu-emacs@gnu.org; Thu, 18 Oct 2012 00:08:59 -0400 Original-Received: from drachen.dragon ([82.113.98.149]) by smtp.web.de (mrweb101) with ESMTPSA (Nemesis) id 0MKrLo-1TOhPl05rM-000mAv; Thu, 18 Oct 2012 06:08:58 +0200 Mail-Followup-To: help-gnu-emacs@gnu.org In-Reply-To: <808vb58pmw.fsf@somewhere.org> (Sebastien Vauban's message of "Wed, 17 Oct 2012 10:32:55 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux) X-Provags-ID: V02:K0:bFSsnb18GaCPpkkF4Yd1VfuL3nAj7aMxup3QyjkgU3O LVDX5y4vcwvMP3IFM0xMfUOL4EmtGM2FJ1ly5slRXCCm79YJIb 3OgpVsy6zmxoTX0oKDvQvLyIwNrI4kYjgmdOXNN3uSJSIxWlxj yqPgFRUMmjSW5A5QMGFSsCEkJ0whKH4RxIBZVRplOX3wPGMeTw UWzDdFYUcjt8QMarhki+8fohjwuzfDNFd5OU9MAk5U= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.227.17.11 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:87306 Archived-At: "Sebastien Vauban" writes: > > 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?* This is absolutely what one would expect. Whenever a variable x has a buffer local binding in a buffer b, and you eval (setq x foo) while b is current, this _always_ sets the local binding of x in b. `eval-after-load' isn't special here in any regard. It's just the fact that you let it eval a setq form with a current buffer that has already local bindings. So, setq is the wrong function for you to use in such a context. If you want to set the default value of a variable, _always_ use setq-default when the variable may already have local bindings in effect. > > 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? Of course you can. `setq' and `setq-default' both accept any symbol. The difference is just that - setq sets the default value if no buffer local binding is currently in effect, else, it sets the local binding - setq-default always sets the default binding In addition, there is a special case of variables that are automatically buffer-local when they are set in any fashion. You should really read the chapters Variables > Buffer-Local Variables and > File Local Variables in the Elisp manual. It describes it much better. Michael.