From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jamie Lokier Newsgroups: gmane.emacs.bugs,gmane.emacs.pretest.bugs Subject: bug#4146: 23.1.50; c-file-style in buffer local variables does not work! Date: Sat, 15 Aug 2009 04:41:12 +0100 Message-ID: <20090815034112.GA30719@shareable.org> Reply-To: Jamie Lokier , 4146@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1250312276 11667 80.91.229.12 (15 Aug 2009 04:57:56 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 15 Aug 2009 04:57:56 +0000 (UTC) To: emacs-pretest-bug@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Aug 15 06:57:49 2009 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1McBKv-0007al-Cw for geb-bug-gnu-emacs@m.gmane.org; Sat, 15 Aug 2009 06:57:49 +0200 Original-Received: from localhost ([127.0.0.1]:41929 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1McBKu-0007OJ-Ju for geb-bug-gnu-emacs@m.gmane.org; Sat, 15 Aug 2009 00:57:48 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1McAXh-0002pZ-7J for bug-gnu-emacs@gnu.org; Sat, 15 Aug 2009 00:06:57 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1McAXc-0002mC-QZ for bug-gnu-emacs@gnu.org; Sat, 15 Aug 2009 00:06:56 -0400 Original-Received: from [199.232.76.173] (port=55228 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1McAXc-0002m8-Eb for bug-gnu-emacs@gnu.org; Sat, 15 Aug 2009 00:06:52 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:39649) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1McAXb-00025b-Op for bug-gnu-emacs@gnu.org; Sat, 15 Aug 2009 00:06:52 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n7F46n0G031174; Fri, 14 Aug 2009 21:06:49 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.14.3/8.14.3/Submit) id n7F3o6Kc027733; Fri, 14 Aug 2009 20:50:06 -0700 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: Jamie Lokier Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Sat, 15 Aug 2009 03:50:06 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: report 4146 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by submit@emacsbugs.donarmstrong.com id=B.125030768126351 (code B ref -1); Sat, 15 Aug 2009 03:50:06 +0000 Original-Received: (at submit) by emacsbugs.donarmstrong.com; 15 Aug 2009 03:41:21 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from fencepost.gnu.org (fencepost.gnu.org [140.186.70.10]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n7F3fJYH026348 for ; Fri, 14 Aug 2009 20:41:21 -0700 Original-Received: from mx10.gnu.org ([199.232.76.166]:42710) by fencepost.gnu.org with esmtp (Exim 4.67) (envelope-from ) id 1McA8t-0002Sq-9g for emacs-pretest-bug@gnu.org; Fri, 14 Aug 2009 23:41:19 -0400 Original-Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1McA8r-0007bV-Cc for emacs-pretest-bug@gnu.org; Fri, 14 Aug 2009 23:41:18 -0400 Original-Received: from mail2.shareable.org ([80.68.89.115]:56207) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1McA8r-0007b1-1Z for emacs-pretest-bug@gnu.org; Fri, 14 Aug 2009 23:41:17 -0400 Original-Received: from jamie by mail2.shareable.org with local (Exim 4.63) (envelope-from ) id 1McA8m-00082N-CQ for emacs-pretest-bug@gnu.org; Sat, 15 Aug 2009 04:41:12 +0100 Content-Disposition: inline User-Agent: Mutt/1.5.13 (2006-08-11) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 1) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Resent-Date: Sat, 15 Aug 2009 00:06:56 -0400 X-Mailman-Approved-At: Sat, 15 Aug 2009 00:57:12 -0400 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:30187 gmane.emacs.pretest.bugs:24955 Archived-At: Hi, In GNU Emacs 23.1.50.1 (i486-pc-linux-gnu, GTK+ Version 2.16.1) of 2009-07-31 on lansones, modified by Debian (emacs-snapshot package, version 1:20090730-1~jaunty1) (= the Ubuntu-PPA Jaunty package at the time of writing) In theory, if you put this at the top of a file, you'd expect C indentation style to be Linux style instead of the default GNU style (it's just an example): -*- c-file-style: "linux" -*- I have just opened a fresh new emacs-23.1.50.1 with "emacs -Q -nw" and then opened a file called foo.c containing that line. What I found is that the variable c-file-style is set to "linux" and is buffer-local, but it does not have the effect of setting the C indentation style. This is the output of C-h v c-file-style RET from that buffer: c-file-style is a variable defined in `cc-vars.el'. Its value is "linux" Local in buffer foo.c; global value is nil Automatically becomes buffer-local when set in any fashion. This variable is a file local variable. This variable is safe as a file local variable if its value satisfies the predicate `string-or-null-p'. The problem is that the variable is set correctly, but the intended effect of setting the C indentation style does not happen. I found this originally when I attempted to set a .dir-locals.el file for a project, exactly the way it is documented in the Emacs manual under "Per-Directory Local Variables": ((nil . ((indent-tabs-mode . t) (tab-width . 8) (fill-column . 79))) (c-mode . ((c-file-style . "linux")))) It turns out that doesn't work either, and then I confirmed it has the same problem when c-file-style is file-local. A bit of debugging reveals that this is called from cc-mode.el.gz, when the file-local variable is set: (c-set-style "GNU" t) (c-set-style "linux" t) So c-file-style does trigger a call to c-set-style. Trouble is, that third argument t means "don't override settings already set", and they were already set by the first call. The first call always happens, and it sets the default style. Fortunately I found a workaround in my .dir-locals.el file that does not ask questions: ((c-mode . ((eval . (c-set-style "linux"))))) Since the entire purpose of c-file-style is to do exactly this, and since it's documented in both the Emacs manual as well as the CC Mode manual, it's clear that it's broken. All this is with "emacs -Q": no customisations. Thanks, -- Jamie