From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nix Newsgroups: gmane.emacs.devel Subject: Re: [RFC PATCH] setting indentation styles via `c-file-style' fails to actually change indentation Date: Thu, 02 Jun 2011 22:43:06 +0100 Message-ID: <87fwnrsydx.fsf@spindle.srvr.nix> References: <87pqngewwp.fsf@spindle.srvr.nix> <87wrh5tyh7.fsf@spindle.srvr.nix> <20110602122412.GA2448@acm.acm> <87fwnstc2z.fsf@spindle.srvr.nix> <20110602211529.GA4904@acm.acm> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1307051023 18688 80.91.229.12 (2 Jun 2011 21:43:43 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 2 Jun 2011 21:43:43 +0000 (UTC) Cc: Stefan Monnier , emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jun 02 23:43:30 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QSFfu-0005OS-5P for ged-emacs-devel@m.gmane.org; Thu, 02 Jun 2011 23:43:30 +0200 Original-Received: from localhost ([::1]:47916 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QSFft-0001aV-Dw for ged-emacs-devel@m.gmane.org; Thu, 02 Jun 2011 17:43:29 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:48010) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QSFfc-0001a4-1Y for emacs-devel@gnu.org; Thu, 02 Jun 2011 17:43:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QSFfa-00037B-Bm for emacs-devel@gnu.org; Thu, 02 Jun 2011 17:43:11 -0400 Original-Received: from icebox.esperi.org.uk ([81.187.191.129]:60526 helo=mail.esperi.org.uk) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QSFfZ-00036M-MX for emacs-devel@gnu.org; Thu, 02 Jun 2011 17:43:10 -0400 Original-Received: from esperi.org.uk (nix@spindle.srvr.nix [192.168.14.15]) by mail.esperi.org.uk (8.14.4/8.14.3) with ESMTP id p52Lh6jc003778; Thu, 2 Jun 2011 22:43:06 +0100 Original-Received: (from nix@localhost) by esperi.org.uk (8.14.4/8.12.11/Submit) id p52Lh6AO018996; Thu, 2 Jun 2011 22:43:06 +0100 Emacs: it's not slow --- it's stately. In-Reply-To: <20110602211529.GA4904@acm.acm> (Alan Mackenzie's message of "Thu, 2 Jun 2011 21:15:29 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-DCC-STAT_FI_X86_64_VIRTUAL-Metrics: spindle 1245; Body=3 Fuz1=3 Fuz2=3 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 81.187.191.129 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:140104 Archived-At: On 2 Jun 2011, Alan Mackenzie stated: > Hi, Nix. > > On Thu, Jun 02, 2011 at 05:47:16PM +0100, Nix wrote: >> On 2 Jun 2011, Alan Mackenzie told this: >> > At a guess, the bug is caused by calling c-file-style with a setting of >> > `dont-override' which causes it to choke on the above hacks. > >> Er, yes. Did you miss my original post? 'cos I came to that conclusion, > > Sorry, I got a bit confused by the length of your post. That's fine, I had trouble understanding it myself :) >> and have a patch, which works for me, at least... but it's rather ugly, >> so if there is a better way which would still allow setting of styles on >> file-by-file and directory-(class)-by-directory-(class) basis, then I'm >> glad to try that instead! > > I'm concerned that adding the extra value 'default to dont-override, and > also the two extra variables, might be an unwarranted increase in > complexity. Yes :( but every other solution seemed to be even *more* complex. > But first, I'd like to understand exactly what the bug is. For a start, > _please_ tell me which version of Emacs you're testing with. Anyhow, > ... This happens with trunk Emacs (24.1-to-be). >> Now. Add that same c-file-style as a file-local or directory-local >> variable to that other style. Reopen it. 'c-basic-offset' hasn't >> changed from the 'gnu' default, but 'c-indentation-style' proclaims >> that the style has in fact been set. In fact, 'c-basic-offset' is >> permanently stuck at the value specified for 'gnu', no matter what >> style you asked for. And this is true for every single variable that >> is set by the 'gnu' style, and for the pieces of 'c-offsets-alist' as >> well. > > I think what you're saying is that in a file like this, > > int main (int argc, char *argv[]) > { > printf ("Hello, world!\n") ; > } > /* Local Variables: */ > /* c-file-style : "linux" */ > /* End: */ > > , c-basic-offset remains 4, when it ought to become 8. Is this in fact > the bug you have found? Not quite. In a file like this: int main (int argc, char *argv[]) { printf ("Hello, world!\n") ; } with this style in effect: (c-add-style "otbs" '("bsd" (c-offsets-alist . ((statement-cont . 4) (inextern-lang . 0) (label . 0) (arglist-cont-nonempty . 4)))))) and with directory local variables set (in my case) via (dir-locals-set-class-variables 'unix '((c-mode . ((c-file-style . "otbs") (fill-column . 80) (indent-tabs-mode . t))))) and the file assigned to the 'unix directory class, not a single one of the 'otbs style elements take effect. Neither do the inherited 'bsd elements. This differs from your case firstly because it tests style inheritance, which is all tangled up with this, and secondly because it tests dir local variables, which are where the breakage is visible. > Just one thing: are you absolutely sure you got the syntax of your Local > Variables: section correct? If not, I think Emacs just fails to > recognise it without giving an error message. I can never actually remember the syntax of that section, because I hardly ever use it: it's rather unfriendly when working in projects where most members don't use Emacs, and apt to be inconsistent as files you do not create don't have any of the variables set. Directory local variables solve both these problems :) > [ ... ] >> DONT-OVERRIDE is clearly doing what it is specified to do. However, >> since 'c-set-style' may be called more than once when initializing a >> buffer, ..... > > Critical here is what value of `dont-override' is used in each of these > calls. Well, it's called once at initialization time with the c-default-style with dont-override set to 't' iff, oh, gods, you can read that code as well as I can and I'm too smashed on antihistamines to parse it right now. Then it gets called again in `c-before-hack-hook' with dont-override set to 't' iff the only c-file-style was in the directory local variable. (The rationale for this remains opaque to me, but since the underlying bug in my case was in the first part I didn't investigate that bit too closely. The style doesn't end up set to the directory- local style: it ends up set to the default!) Plus, each of these calls the underlying style-addition function repeatedly for inherited styles. >> ... the net effect of these semantics is to set variables which are >> defined in the 'c-default-style' as well as in the 'c-file-style' to >> their values in the 'c-default-style', which is surely wrong: the >> 'c-default-style' is a global fallback, and should not take precedence >> over per-file or per-directory indentation styles. > > That is true. The question is why is the c-set-style for the > `c-file-style' not doing its job?. Normally it would override the > default style just set up. It doesn't :( again, the email describes it more clearly than I can in my current hayfever-wrecked state. > Anyhow, first I need to be able to reproduce the bug. Any help you can > give me with this will be most appreciated. Maybe the pollen count will go down soon and I can think about this more clearly... -- NULL && (void)