GNU bug report logs - #17051
Order of evaluation in .dir-locals.el

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs,cc-mode; Severity: minor; Reported by: Reuben Thomas <rrt@HIDDEN>; Keywords: confirmed; dated Thu, 20 Mar 2014 15:02:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 17051 <at> debbugs.gnu.org:


Received: (at 17051) by debbugs.gnu.org; 7 Jun 2016 11:23:08 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jun 07 07:23:08 2016
Received: from localhost ([127.0.0.1]:57503 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1bAF6C-0001n4-Ax
	for submit <at> debbugs.gnu.org; Tue, 07 Jun 2016 07:23:08 -0400
Received: from mail.muc.de ([193.149.48.3]:38261)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <acm@HIDDEN>) id 1bAF69-0001mr-Al
 for 17051 <at> debbugs.gnu.org; Tue, 07 Jun 2016 07:23:06 -0400
Received: (qmail 44224 invoked by uid 3782); 7 Jun 2016 11:23:04 -0000
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
Received: (qmail 3724 invoked by uid 1000); 7 Jun 2016 11:23:13 -0000
Date: Tue, 7 Jun 2016 11:23:13 +0000
To: Reuben Thomas <rrt@HIDDEN>
Subject: Re: bug#17051: Order of evaluation in .dir-locals.el
Message-ID: <20160607112313.GA3681@HIDDEN>
References: <CAOnWdogi4gQtDAY5imOsS1tHyhvsO5niztG687LyD2hwh4xMKw@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <CAOnWdogi4gQtDAY5imOsS1tHyhvsO5niztG687LyD2hwh4xMKw@HIDDEN>
User-Agent: Mutt/1.5.24 (2015-08-30)
X-Delivery-Agent: TMDA/1.1.12 (Macallan)
From: Alan Mackenzie <acm@HIDDEN>
X-Primary-Address: acm@HIDDEN
X-Spam-Score: -1.4 (-)
X-Debbugs-Envelope-To: 17051
Cc: 17051 <at> debbugs.gnu.org, Noam Postavsky <npostavs@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.4 (-)

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).




Information forwarded to bug-gnu-emacs@HIDDEN, bug-cc-mode@HIDDEN:
bug#17051; Package emacs,cc-mode. Full text available.

Message received at 17051 <at> debbugs.gnu.org:


Received: (at 17051) by debbugs.gnu.org; 7 Jun 2016 00:41:26 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jun 06 20:41:26 2016
Received: from localhost ([127.0.0.1]:57292 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1bA55C-0001gs-Co
	for submit <at> debbugs.gnu.org; Mon, 06 Jun 2016 20:41:26 -0400
Received: from mail-oi0-f52.google.com ([209.85.218.52]:34886)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <npostavs@HIDDEN>) id 1bA55A-0001gg-1F
 for 17051 <at> debbugs.gnu.org; Mon, 06 Jun 2016 20:41:24 -0400
Received: by mail-oi0-f52.google.com with SMTP id s139so13841374oie.2
 for <17051 <at> debbugs.gnu.org>; Mon, 06 Jun 2016 17:41:23 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
 h=mime-version:sender:in-reply-to:references:from:date:message-id
 :subject:to:cc;
 bh=V/TfIN3hW3KxQBJsvp9kCGySP9VvVmPEQ81fJStVNH0=;
 b=nYdkgpikj1De/Q28FPyIjH8tJ/9bt4CMTlOFNxE1EgKOmhEz7MlbyfW8p31+saQlTK
 b16NV/oxvwaRyhUcJoMNf76Tc8QTvDdGjxLTj+4V8bGTs4Y8HZYpb9xPVvJBNNscqKNu
 v4MX9PE2b1qGu9PAS8m+lxZcvRLMtIbLye5ud0tYgHlTgftGz2gDB6+mgyMGFUPFQice
 uRiUmYx8Vbb3Kd+7pDrL/40RAqW1q0UJ4yWb7lOCwcQfnKzmbgcOLrPWi0FQN8Xkm6ZO
 3NHlumAJX4qqYbdSjvVEMNvGxVzNuvnW+wu6KNnT6p7XCInFaHtxQTXIhlnMOHDvIO3s
 x7KQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20130820;
 h=x-gm-message-state:mime-version:sender:in-reply-to:references:from
 :date:message-id:subject:to:cc;
 bh=V/TfIN3hW3KxQBJsvp9kCGySP9VvVmPEQ81fJStVNH0=;
 b=FaK7ZpPDhRB9/TWnCKNq46Bod54Z3jSHe23tVlsYlETIWdX26B10HXCGE66RBs3ycf
 SXu7t/ckqQNiw7b2fkfz3EaR4FIcegG57mscn95uZgC5fpWeukS/z/9GoKLQjnCYJ+aR
 A5g2TRX89EScB+p6Fpu/ymuKYMT2E9YNvRK19NPyyG/irtTsuStPyugSnZYxaI1AbLTX
 rIxjEFcUtmPl6bSvfsdZbjF298d7QtGVno2Pr8qhtMqGKSB4KqQ2RFGZCX6ph8O818C1
 qzysHQquIzSNUQU5iEhp2eZ+Dhf/4FPS51RZeMqDka9C6UZ3Y3y0tnqdcR7iAytLQxKb
 mb5Q==
X-Gm-Message-State: ALyK8tJMjeOXN+DhQHNQmqdMZmybXwaRPw3APlUWhMD4kzQVaOVW1ecR1w1e+/GKx8VDCg3gWsnFWacwZWcyXQ==
X-Received: by 10.157.23.195 with SMTP id j61mr11179649otj.92.1465260078348;
 Mon, 06 Jun 2016 17:41:18 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.157.5.168 with HTTP; Mon, 6 Jun 2016 17:41:17 -0700 (PDT)
In-Reply-To: <CAOnWdogXr4O4Hia=5UEWMUTZ_q1VXeg74p37ZBMFqu1DJMo9Bw@HIDDEN>
References: <CAM-tV-8hpbeeC7dr7oyDkYPSyPMxSDOeaHkHE+Kevmqg9D3+rA@HIDDEN>
 <CAOnWdogXr4O4Hia=5UEWMUTZ_q1VXeg74p37ZBMFqu1DJMo9Bw@HIDDEN>
From: Noam Postavsky <npostavs@HIDDEN>
Date: Mon, 6 Jun 2016 20:41:17 -0400
X-Google-Sender-Auth: gvk5kWTcNrBAs2bWTf63iVso6l0
Message-ID: <CAM-tV-98h2q1kjQnX6YWamBcNGu2fUH=n5ce4MotRgzj084Jig@HIDDEN>
Subject: Re: Order of evaluation in .dir-locals.el
To: Reuben Thomas <rrt@HIDDEN>
Content-Type: text/plain; charset=UTF-8
X-Spam-Score: -0.5 (/)
X-Debbugs-Envelope-To: 17051
Cc: 17051 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.5 (/)

On Sun, Jun 5, 2016 at 3:38 PM, Reuben Thomas <rrt@HIDDEN> wrote:
> Thanks very much; to check I understand, you're saying that at present it's
> not possible to do this all in .dir-locals.el; I'd have presumably to define
> the style in my Emacs init sequence (or anyway, load it before visiting the
> directory)?

Yes (though I suppose you might be able to make it work by removing
`c-before-hack-hook' and performing `c-set-style' yourself).




Information forwarded to bug-gnu-emacs@HIDDEN, bug-cc-mode@HIDDEN:
bug#17051; Package emacs,cc-mode. Full text available.

Message received at 17051 <at> debbugs.gnu.org:


Received: (at 17051) by debbugs.gnu.org; 5 Jun 2016 19:38:49 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jun 05 15:38:49 2016
Received: from localhost ([127.0.0.1]:55903 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1b9dsn-000672-5w
	for submit <at> debbugs.gnu.org; Sun, 05 Jun 2016 15:38:49 -0400
Received: from mail-wm0-f52.google.com ([74.125.82.52]:36853)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rrt@HIDDEN>) id 1b9dsl-00066q-Fg
 for 17051 <at> debbugs.gnu.org; Sun, 05 Jun 2016 15:38:48 -0400
Received: by mail-wm0-f52.google.com with SMTP id n184so64124763wmn.1
 for <17051 <at> debbugs.gnu.org>; Sun, 05 Jun 2016 12:38:47 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sc3d.org; s=google;
 h=mime-version:in-reply-to:references:from:date:message-id:subject:to
 :cc; bh=P5ohpRn+tVwtpL9WR3Z7gL2GhobDxBrjllQb4S1rCSw=;
 b=ucsuLg1uLk47MjLHEoSx+QWxo3JuYDKaZHiOaLJx3LH5UyG7JhreW5SCKn4VlE7I9B
 1UewGSoJYRfJMA0x0RypmfRhdcdrLuU5S/fs27k2vdk5shNlU/aBsZeX2IZ8E7+2BfT+
 NhQxT1qazugbq4VuMP8NvvmX7ec6GwKvTaLrQ=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20130820;
 h=x-gm-message-state:mime-version:in-reply-to:references:from:date
 :message-id:subject:to:cc;
 bh=P5ohpRn+tVwtpL9WR3Z7gL2GhobDxBrjllQb4S1rCSw=;
 b=LBEaZeNIsGyrYsGcf4WpzKbWPRCYaucXxqs1kNIb5xAjYraHOtN6zs0ZyIgdX+qu/I
 MFtVgAEq7/EhkZ7c33GxZ7s/YkhZKRkYhgPWFbnKpTI8A3xpjfahYJLwF3rDsGxoGuTl
 AKt8jS76GQ5AWl6K+irYl+Fznyns+GbDJNOhCBD4+nirS5N9aFojvjx8Gebp27yqCfkh
 RIbbDczMGW63Y2QW0hZEsDfpKobVXGhfK3hQooAkGHzjsteoGWyestH+Mue7wK/9CX4F
 JPLBEd6zt0hXSCaPKsUKtH3m5eSCA3JVTxJSzpAryM9F327wvKJzmdeh5Ni3k73YdJOF
 BSjA==
X-Gm-Message-State: ALyK8tK9KBeREJ2dsVdukWZa28rur8j+EMQfUOtnQhm0CRzDnYm6orSugkqrb8KloUouJZCth/y8yXzyIlCvf/Wm
X-Received: by 10.28.9.14 with SMTP id 14mr3360203wmj.50.1465155521774; Sun,
 05 Jun 2016 12:38:41 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.194.221.226 with HTTP; Sun, 5 Jun 2016 12:38:40 -0700 (PDT)
In-Reply-To: <CAM-tV-8hpbeeC7dr7oyDkYPSyPMxSDOeaHkHE+Kevmqg9D3+rA@HIDDEN>
References: <CAM-tV-8hpbeeC7dr7oyDkYPSyPMxSDOeaHkHE+Kevmqg9D3+rA@HIDDEN>
From: Reuben Thomas <rrt@HIDDEN>
Date: Sun, 5 Jun 2016 20:38:40 +0100
Message-ID: <CAOnWdogXr4O4Hia=5UEWMUTZ_q1VXeg74p37ZBMFqu1DJMo9Bw@HIDDEN>
Subject: Re: Order of evaluation in .dir-locals.el
To: Noam Postavsky <npostavs@HIDDEN>
Content-Type: multipart/alternative; boundary=001a1143b0b66a9d0705348d1aaa
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 17051
Cc: 17051 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

--001a1143b0b66a9d0705348d1aaa
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On 4 June 2016 at 23:02, Noam Postavsky <npostavs@HIDDEN>
wrote:

>
> Of course `before-hack-local-variables-hook' runs before any local
> variables are set, so there is no "correct" order that a user can use
> in .dir-locals.el to define a new style: `c-file-style' always applies
> before any other variables.
>

=E2=80=8BThanks very much; to check I understand, you're saying that at pre=
sent
it's not possible to do this all in .dir-locals.el; I'd have presumably to
define the style in my Emacs init sequence (or anyway, load it before
visiting the directory)?

--=20
http://rrt.sc3d.org

--001a1143b0b66a9d0705348d1aaa
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_default" style=3D"font-size:small">On =
4 June 2016 at 23:02, Noam Postavsky <span dir=3D"ltr">&lt;<a href=3D"mailt=
o:npostavs@HIDDEN" target=3D"_blank">npostavs@HIDDEN=
rge.net</a>&gt;</span> wrote:<br></div><div class=3D"gmail_extra"><div clas=
s=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .=
8ex;border-left:1px #ccc solid;padding-left:1ex"><br>Of course `before-hack=
-local-variables-hook&#39; runs before any local<br>
variables are set, so there is no &quot;correct&quot; order that a user can=
 use<br>
in .dir-locals.el to define a new style: `c-file-style&#39; always applies<=
br>
before any other variables.<br>
</blockquote></div><br><div class=3D"gmail_default" style=3D"font-size:smal=
l">=E2=80=8BThanks very much; to check I understand, you&#39;re saying that=
 at present it&#39;s not possible to do this all in .dir-locals.el; I&#39;d=
 have presumably to define the style in my Emacs init sequence (or anyway, =
load it before visiting the directory)?</div><div><br></div>-- <br><div cla=
ss=3D"gmail_signature" data-smartmail=3D"gmail_signature"><a href=3D"http:/=
/rrt.sc3d.org" target=3D"_blank">http://rrt.sc3d.org</a></div>
</div></div>

--001a1143b0b66a9d0705348d1aaa--




Information forwarded to bug-gnu-emacs@HIDDEN, bug-cc-mode@HIDDEN:
bug#17051; Package emacs,cc-mode. Full text available.
Added tag(s) confirmed. Request was from Noam Postavsky <npostavs@HIDDEN> to control <at> debbugs.gnu.org. Full text available.
Severity set to 'minor' from 'normal' Request was from Noam Postavsky <npostavs@HIDDEN> to control <at> debbugs.gnu.org. Full text available.
bug reassigned from package 'emacs' to 'emacs,cc-mode'. Request was from Noam Postavsky <npostavs@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 17051 <at> debbugs.gnu.org:


Received: (at 17051) by debbugs.gnu.org; 4 Jun 2016 22:02:20 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jun 04 18:02:20 2016
Received: from localhost ([127.0.0.1]:54667 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1b9Je8-0006MY-7u
	for submit <at> debbugs.gnu.org; Sat, 04 Jun 2016 18:02:20 -0400
Received: from mail-oi0-f48.google.com ([209.85.218.48]:33859)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <npostavs@HIDDEN>) id 1b9Je6-0006M5-Ng
 for 17051 <at> debbugs.gnu.org; Sat, 04 Jun 2016 18:02:18 -0400
Received: by mail-oi0-f48.google.com with SMTP id e72so176697320oib.1
 for <17051 <at> debbugs.gnu.org>; Sat, 04 Jun 2016 15:02:18 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
 h=mime-version:sender:from:date:message-id:subject:to:cc
 :content-transfer-encoding;
 bh=k5RDOTCwFhtMmvuvus4RymuTcDbktFNaiHnJnp1bK0o=;
 b=MEEceY1nLIazhb25MwHrP0qo0rSeMtbspcyV+X9F0IRneFSzspLOu/hznFVacdg0gu
 R49kYOITXpDT7+YK7JHXqP8XcILs4h0z0ryi/G8ftfJyYdlizaNmBNS65E11enpT1YjY
 gJWGWQFkFuyuPnQQjqNQfTflbGhJySjBvC9EI6uVP3KhSNTfoODt+FUSTumrWoCEGz01
 NrZS700ZRN6laj02FfTVppyiDnQfezJK3dcJsFQ1OD86eY6aTPChHl5+hbkV/sI5WhNj
 Y9hjNewLVajt2N+3v+RM8BitNYQaKSXkcMVaujzGiZ8atWKeYJIVOUU2U+DBEbo6emdP
 0GwQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20130820;
 h=x-gm-message-state:mime-version:sender:from:date:message-id:subject
 :to:cc:content-transfer-encoding;
 bh=k5RDOTCwFhtMmvuvus4RymuTcDbktFNaiHnJnp1bK0o=;
 b=Spy7gfQFv2kEYoyeIZtaL/ZDUpSeoaVDWQUnQCmMVUJBl3mm/8LkjGcrwPugovS/a8
 gU7WNH6MucP/pnTw9iLgE0OByYWXNxg0XqNcQ9bHRMN51MAoxw2osFHbzLSw/WCA8zUo
 +YnH+7P04LpUs7NOEVlqjx7ghbZ45yu/10Wdy2BjNyk9Yhe2Kec5ANIY8vTiJwN1t99n
 50jDuGHFObr2NVORkuubmHJTxne2Jazsv7WlBmnklXSHoW7AYs5+Znn/6iF7woASCs0S
 ULoyBlxiQnPTJk7kDGOGezyHikV3r/DWNflw6DqzNsfCm16DItyDUyz1Iw6gfG5+Aj3p
 qPhA==
X-Gm-Message-State: ALyK8tK9D9sZD4YEUTNenMDlVHe77y7z7yozFO6MJBP1M7LgqnnZnAkVMDrHgPwCScfckYqXFZM6zeXFA1K4Fw==
X-Received: by 10.202.77.78 with SMTP id a75mr4520240oib.88.1465077728025;
 Sat, 04 Jun 2016 15:02:08 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.157.5.168 with HTTP; Sat, 4 Jun 2016 15:02:07 -0700 (PDT)
From: Noam Postavsky <npostavs@HIDDEN>
Date: Sat, 4 Jun 2016 18:02:07 -0400
X-Google-Sender-Auth: BDS23hJnOZzCME7rIlCQ51MlIHs
Message-ID: <CAM-tV-8hpbeeC7dr7oyDkYPSyPMxSDOeaHkHE+Kevmqg9D3+rA@HIDDEN>
Subject: Order of evaluation in .dir-locals.el
To: 17051 <at> debbugs.gnu.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -0.5 (/)
X-Debbugs-Envelope-To: 17051
Cc: Reuben Thomas <rrt@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.5 (/)

reassign 17051 emacs,cc-mode
severity 17051 minor
tag 17051 + confirmed
quit

The reason this doesn't work is revealed in the docstring of c-before-hook:

c-before-hack-hook is a compiled Lisp function in =E2=80=98cc-mode.el=E2=80=
=99.

(c-before-hack-hook)

Set the CC Mode style and "offsets" when in the buffer=E2=80=99s local vari=
ables.
They are set only when, respectively, the pseudo variables
=E2=80=98c-file-style=E2=80=99 and =E2=80=98c-file-offsets=E2=80=99 are pre=
sent in the list.

This function is called from the hook =E2=80=98before-hack-local-variables-=
hook=E2=80=99.

Of course `before-hack-local-variables-hook' runs before any local
variables are set, so there is no "correct" order that a user can use
in .dir-locals.el to define a new style: `c-file-style' always applies
before any other variables.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#17051; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 20 Mar 2014 15:01:30 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 20 11:01:29 2014
Received: from localhost ([127.0.0.1]:42415 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1WQeTJ-0008Tp-CM
	for submit <at> debbugs.gnu.org; Thu, 20 Mar 2014 11:01:29 -0400
Received: from eggs.gnu.org ([208.118.235.92]:48500)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <rrt@HIDDEN>) id 1WQeTF-0008Tg-HK
 for submit <at> debbugs.gnu.org; Thu, 20 Mar 2014 11:01:26 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <rrt@HIDDEN>) id 1WQeTE-0001IC-6E
 for submit <at> debbugs.gnu.org; Thu, 20 Mar 2014 11:01:25 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,HTML_MESSAGE,
 T_DKIM_INVALID autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:54649)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <rrt@HIDDEN>)
 id 1WQeTE-0001I6-4E
 for submit <at> debbugs.gnu.org; Thu, 20 Mar 2014 11:01:24 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:50200)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <rrt@HIDDEN>) id 1WQeT9-0006iv-Pi
 for bug-gnu-emacs@HIDDEN; Thu, 20 Mar 2014 11:01:24 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <rrt@HIDDEN>) id 1WQeT8-0001HL-9N
 for bug-gnu-emacs@HIDDEN; Thu, 20 Mar 2014 11:01:19 -0400
Received: from fencepost.gnu.org ([2001:4830:134:3::e]:44336)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <rrt@HIDDEN>)
 id 1WQeT8-0001HH-5u
 for bug-gnu-emacs@HIDDEN; Thu, 20 Mar 2014 11:01:18 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:46121)
 by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <rrt@HIDDEN>) id 1WQeT7-0006MN-MO
 for bug-emacs@HIDDEN; Thu, 20 Mar 2014 11:01:17 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <rrt@HIDDEN>) id 1WQeT3-0001G8-A8
 for bug-emacs@HIDDEN; Thu, 20 Mar 2014 11:01:17 -0400
Received: from mail-yh0-x234.google.com ([2607:f8b0:4002:c01::234]:48636)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <rrt@HIDDEN>)
 id 1WQeT3-0001Fu-2q
 for bug-emacs@HIDDEN; Thu, 20 Mar 2014 11:01:13 -0400
Received: by mail-yh0-f52.google.com with SMTP id c41so935004yho.39
 for <bug-emacs@HIDDEN>; Thu, 20 Mar 2014 08:01:12 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sc3d.org; s=google;
 h=mime-version:date:message-id:subject:from:to:content-type;
 bh=oopgpAFOA0zuh+dP+pBwufkZkNRahF7iDFgBgqR3MNA=;
 b=p6TxjK6rscF+INMk/vh8ytzJ1EkEAy3erf7k13sL/EPAoTKbIsVf2SRR90xayPtdz2
 3HopXStNT2eeojJDsJsLJWMOR5gDCQilTiF0MqelrGYecTqIpJGh9ds5wbh3wIjouSAc
 +0brlPy6lINSZIEiBVevFN4wl5xvCgFPLhj0A=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20130820;
 h=x-gm-message-state:mime-version:date:message-id:subject:from:to
 :content-type;
 bh=oopgpAFOA0zuh+dP+pBwufkZkNRahF7iDFgBgqR3MNA=;
 b=bHw5n6299pUu8MU+KhclYgpV6ZZIdbY6B3BexIhyGYR7yiSZoBx1y9JPulQptQ3MaM
 FKnGlqZ7KaWYNRKXJiUXeJqqCvftN6azh878O1/j40dEhJGqWpIoKTaxrjQbje4C2wSS
 QgddrNig6032sGZ195ITrnl4PCMoE+2qzhbEgh0tlz5FRCnvxpp7LcGXx7NdV0lq06Jg
 yMR1+lZryoW1jNfhkqimM7a/rPWjc2lf1DwdFHLBGOsmKciCRFsbe8fJy/KMbZ/KY2y1
 idgfx3ts9b+xPtM7cs1T/yoF7mcgKRJMZvec8mmLlRo1MxtabOaRiTJJhT9lUw4Dpkzr
 BKGA==
X-Gm-Message-State: ALoCoQmMYdPtVlQ7cB9E/vSSxS4JpZYIMl0DvEz51HubrOa7tFqJ2Hw+B91RyqPt5Jk09qkOiSnQ
MIME-Version: 1.0
X-Received: by 10.236.32.103 with SMTP id n67mr1515744yha.73.1395327672153;
 Thu, 20 Mar 2014 08:01:12 -0700 (PDT)
Received: by 10.170.137.66 with HTTP; Thu, 20 Mar 2014 08:01:12 -0700 (PDT)
Date: Thu, 20 Mar 2014 15:01:12 +0000
Message-ID: <CAOnWdogi4gQtDAY5imOsS1tHyhvsO5niztG687LyD2hwh4xMKw@HIDDEN>
Subject: Order of evaluation in .dir-locals.el
From: Reuben Thomas <rrt@HIDDEN>
To: bug-emacs <bug-emacs@HIDDEN>
Content-Type: multipart/alternative; boundary=001a11c1f53c3e8fa704f50b0a17
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
 (bad octet value).
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
 (bad octet value).
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
 (bad octet value).
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -4.1 (----)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -4.1 (----)

--001a11c1f53c3e8fa704f50b0a17
Content-Type: text/plain; charset=ISO-8859-1

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.

When I first visit a file under that project, I get the error: "Undefined
style: fontforge"

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.

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?

-- 
http://rrt.sc3d.org

--001a11c1f53c3e8fa704f50b0a17
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div><div><div><div><div><div>I have the following .dir-lo=
cals.el for a project:<br><br>((nil . ((show-trailing-whitespace . nil)<br>=
=A0=A0=A0=A0=A0=A0=A0=A0 (eval . (c-add-style &quot;fontforge&quot;<br>=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0 &#39;(&quot;stroustrup&quot;<br>
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0 (indent-tabs-mode . t)<br>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (tab-width =
. 8)<br>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0 (c-offsets-alist<br>=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (case=
-label . *)))))))<br>=A0(c-mode . ((c-file-style . &quot;fontforge&quot;)))=
)<br>
<br></div>The idea is to define a new c-style and apply it to all files in =
that project.<br><br>When I first visit a file under that project, I get th=
e error: &quot;Undefined style: fontforge&quot;<br><br></div>When I examine=
 c-style-alist, &quot;fontforge&quot; is the first entry, and when I look a=
t c-file-style for that buffer, its value is &quot;fontforge&quot;. 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 &=
quot;nil&quot;, it is still nil.<br>
<br>If I then run M-x c-set-style RET fontforge RET, the style is applied a=
s expected.<br><br></div>Hence, it appears my error has to do with the orde=
r of evaluation. I tried putting the &quot;eval&quot; sexp under the &quot;=
c-mode&quot; section of the .dir-locals.el, but that still gives the same e=
rror, even when I put it before the c-file-style sexp.<br>
<br></div>I can&#39;t find anything about this in the manual, or online (i.=
e. examples where the result of an &quot;eval&quot; entry are relied on by =
another entry). In hack-local-variables-apply files.el I found this bit of =
code:<br>
<br>=A0=A0=A0 ;; Any &#39;evals must run in the Right sequence.<br>=A0=A0=
=A0 (setq file-local-variables-alist<br>=A0=A0=A0 =A0 (nreverse file-local-=
variables-alist))<br><br></div>so I tried putting the &quot;eval&quot; part=
 at the end of c-mode&#39;s list, but that didn&#39;t help either. (I check=
ed file-local-variables-alist in each case to make sure that in one the eva=
l was before c-file-style, and in the other, after).<br>
<br></div>Can someone please set me straight?<br clear=3D"all"><div><div><d=
iv><div><div><div><div><br>-- <br><a href=3D"http://rrt.sc3d.org">http://rr=
t.sc3d.org</a>
</div></div></div></div></div></div></div></div>

--001a11c1f53c3e8fa704f50b0a17--




Acknowledgement sent to Reuben Thomas <rrt@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#17051; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Tue, 7 Jun 2016 11:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.