From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: Patch: Blunderbuss ".dir-locals.el" raises everything in its path!! Date: Wed, 15 Jul 2009 19:00:05 +0000 Message-ID: <20090715190005.GA2380@muc.de> References: <20090712144137.GB2524@muc.de> <87hbxhony6.fsf@stupidchicken.com> <20090712180623.GA1009@muc.de> <87k52dycha.fsf@stupidchicken.com> <4A5AC184.5050805@gnu.org> <20090714162206.GC1718@muc.de> <20090714201150.GA1631@muc.de> <4A5D8B7F.6050603@swipnet.se> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1247684318 20264 80.91.229.12 (15 Jul 2009 18:58:38 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 15 Jul 2009 18:58:38 +0000 (UTC) Cc: emacs-devel@gnu.org, Stefan Monnier , Jason Rumney To: Jan =?iso-8859-1?Q?Dj=E4rv?= , Chong Yidong Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jul 15 20:58:30 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MR9gT-00057d-Ff for ged-emacs-devel@m.gmane.org; Wed, 15 Jul 2009 20:58:30 +0200 Original-Received: from localhost ([127.0.0.1]:45109 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MR9gS-0005jw-VN for ged-emacs-devel@m.gmane.org; Wed, 15 Jul 2009 14:58:29 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MR9gD-0005c3-5A for emacs-devel@gnu.org; Wed, 15 Jul 2009 14:58:13 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MR9g8-0005YW-Iy for emacs-devel@gnu.org; Wed, 15 Jul 2009 14:58:12 -0400 Original-Received: from [199.232.76.173] (port=51679 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MR9g8-0005YH-Eg for emacs-devel@gnu.org; Wed, 15 Jul 2009 14:58:08 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:4336 helo=mail.muc.de) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MR9g7-0004jX-ME for emacs-devel@gnu.org; Wed, 15 Jul 2009 14:58:08 -0400 Original-Received: (qmail 33876 invoked by uid 3782); 15 Jul 2009 18:58:04 -0000 Original-Received: from acm.muc.de (pD9E22F2D.dip.t-dialin.net [217.226.47.45]) by colin2.muc.de (tmda-ofmipd) with ESMTP; Wed, 15 Jul 2009 20:58:00 +0200 Original-Received: (qmail 3824 invoked by uid 1000); 15 Jul 2009 19:00:05 -0000 Content-Disposition: inline In-Reply-To: <4A5D8B7F.6050603@swipnet.se> User-Agent: Mutt/1.5.9i X-Delivery-Agent: TMDA/1.1.5 (Fettercairn) X-Primary-Address: acm@muc.de X-detected-operating-system: by monty-python.gnu.org: FreeBSD 4.6-4.9 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:112501 Archived-At: Hi, Jan, Yidong, On Wed, Jul 15, 2009 at 09:55:43AM +0200, Jan Djärv wrote: > Alan Mackenzie skrev: > >Here's a preliminary patch which I think fixes the code, though I've > >only tested it briefly. It seems to work for the case you (Jan) were > >hit by. > >Now, any CC Mode style set by `c-file-style' will leave unchanged > >those style variables (e.g. `c-cleanup-list') which have already been > >given real values. > >I expect and intend that if the `c-file-style' mechanism is used > >twice, the second one (in the file's Local Variable section) will > >prevail over the first one (in some .dir-locals.el), whilst > >respecting the non-default value of `c-cleanup-list'. > >Jan, please try it out! > It works if I set c-cleanup-list with customize, but not if it is set in > the c-common-mode-hook (using add-to-list). Yes. Sorry. I think we agree that a setting for c-cleanup-list made in a hook function should take priority over any (semi-implicitly) requested by c-file-style. I think I can see how to do this, now. I tried the following settings, at the same time: (i) In .dir-locals.el: (c-mode . ((c-file-style . "Linux") (c-basic-offset . 7))) (ii) In .../src/xftfont.c: /* * Local Variables: * c-file-style: "BSD" * c-basic-offset: 10 * End: */ In xftfont.c, I got the style as "Linux" and c-basic-offset as 10, i.e. a mixture of these two. This happens because the CC Mode routine does (assq 'c-file-style file-local-variables-alist) , hence finding the earliest entry for c-file-style, whilst the other variables are just bashed through, causing the latest entry to prevail over earlier ones. Yidong, hack-local-variables desperately needs refactoring. It was sort of tolerable when only file local variables were involved, but now it's all but unreadable and ununderstandable (should this just be derstandable?) In particular, there's no great care taken about how the local variable settings from the two sources get combined. How about the following idea: when a setting from the Local Variables: section is to be pushed onto file-local-variables-alist, any exisiting element for the same variable is first removed? This way, a file's Local Variables section will prevail over .dir-locals.el. > Jan D. -- Alan Mackenzie (Nuremberg, Germany).