From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#17051: Order of evaluation in .dir-locals.el Date: Tue, 7 Jun 2016 11:23:13 +0000 Message-ID: <20160607112313.GA3681__39967.6928566352$1465299168$gmane$org@acm.fritz.box> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1465299168 25425 80.91.229.3 (7 Jun 2016 11:32:48 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 7 Jun 2016 11:32:48 +0000 (UTC) Cc: 17051@debbugs.gnu.org, Noam Postavsky To: Reuben Thomas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jun 07 13:32:37 2016 Return-path: Envelope-to: geb-bug-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 1bAFFK-0007jH-Va for geb-bug-gnu-emacs@m.gmane.org; Tue, 07 Jun 2016 13:32:35 +0200 Original-Received: from localhost ([::1]:48731 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAFFK-0003pb-8a for geb-bug-gnu-emacs@m.gmane.org; Tue, 07 Jun 2016 07:32:34 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55571) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAF77-00059b-Ml for bug-gnu-emacs@gnu.org; Tue, 07 Jun 2016 07:24:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bAF74-0005tS-CN for bug-gnu-emacs@gnu.org; Tue, 07 Jun 2016 07:24:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:45166) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAF74-0005tM-7D; Tue, 07 Jun 2016 07:24:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bAF74-0001oK-3E; Tue, 07 Jun 2016 07:24:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Tue, 07 Jun 2016 11:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 17051 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: confirmed Original-Received: via spool by 17051-submit@debbugs.gnu.org id=B17051.14652985886890 (code B ref 17051); Tue, 07 Jun 2016 11:24:02 +0000 Original-Received: (at 17051) by debbugs.gnu.org; 7 Jun 2016 11:23:08 +0000 Original-Received: from localhost ([127.0.0.1]:57503 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bAF6C-0001n4-Ax for submit@debbugs.gnu.org; Tue, 07 Jun 2016 07:23:08 -0400 Original-Received: from mail.muc.de ([193.149.48.3]:38261) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bAF69-0001mr-Al for 17051@debbugs.gnu.org; Tue, 07 Jun 2016 07:23:06 -0400 Original-Received: (qmail 44224 invoked by uid 3782); 7 Jun 2016 11:23:04 -0000 Original-Received: from acm.muc.de (p548C6037.dip0.t-ipconnect.de [84.140.96.55]) by colin.muc.de (tmda-ofmipd) with ESMTP; Tue, 07 Jun 2016 13:23:02 +0200 Original-Received: (qmail 3724 invoked by uid 1000); 7 Jun 2016 11:23:13 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:119205 Archived-At: Hello, Reuben. On Thu, Mar 20, 2014 at 03:01:12PM +0000, Reuben Thomas wrote: > I have the following .dir-locals.el for a project: > ((nil . ((show-trailing-whitespace . nil) > (eval . (c-add-style "fontforge" > '("stroustrup" > (indent-tabs-mode . t) > (tab-width . 8) > (c-offsets-alist > (case-label . *))))))) > (c-mode . ((c-file-style . "fontforge")))) > The idea is to define a new c-style and apply it to all files in that > project. Why are you defining the new style "fontforge" every time a file gets visited? Couldn't you simply define it once, directly in your .emacs, before any C files are loaded (e.g., via desktop-save-mode)? > When I first visit a file under that project, I get the error: "Undefined > style: fontforge" I don't think the order of evaluation of variables in .dir-locals.el is defined. The code (in .../lisp/files.el) is not easy to understand. It could well be that, for that first file, the c-file-style is being applied before it has been defined. > When I examine c-style-alist, "fontforge" is the first entry, and when I > look at c-file-style for that buffer, its value is "fontforge". However, as > the error implies, the style has not been applied to that buffer: if I > check the value of indent-tabs-mode, which I have configured globally to > "nil", it is still nil. > If I then run M-x c-set-style RET fontforge RET, the style is applied as > expected. > Hence, it appears my error has to do with the order of evaluation. I tried > putting the "eval" sexp under the "c-mode" section of the .dir-locals.el, > but that still gives the same error, even when I put it before the > c-file-style sexp. Again, I'm not aware of any definition of the order of evaluation. > I can't find anything about this in the manual, or online (i.e. examples > where the result of an "eval" entry are relied on by another entry). In > hack-local-variables-apply files.el I found this bit of code: > ;; Any 'evals must run in the Right sequence. > (setq file-local-variables-alist > (nreverse file-local-variables-alist)) > so I tried putting the "eval" part at the end of c-mode's list, but that > didn't help either. (I checked file-local-variables-alist in each case to > make sure that in one the eval was before c-file-style, and in the other, > after). > Can someone please set me straight? Would you please try defining your CC Mode style outside of .dir-locals.el, as suggested above. It could well be that we need to polish the documentation of this topic a little. > -- > http://rrt.sc3d.org -- Alan Mackenzie (Nuremberg, Germany).