GNU bug report logs - #4146
23.1.50; c-file-style in buffer local variables does not work!

Previous Next

Packages: emacs, cc-mode;

Reported by: Jamie Lokier <jamie <at> shareable.org>

Date: Sat, 15 Aug 2009 03:50:06 UTC

Severity: normal

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 4146 in the body.
You can then email your comments to 4146 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4146; Package emacs. (Sat, 15 Aug 2009 03:50:06 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jamie Lokier <jamie <at> shareable.org>:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Sat, 15 Aug 2009 03:50:06 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Jamie Lokier <jamie <at> shareable.org>
To: emacs-pretest-bug <at> gnu.org
Subject: 23.1.50; c-file-style in buffer local variables does not work!
Date: Sat, 15 Aug 2009 04:41:12 +0100
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



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4146; Package emacs. (Sat, 15 Aug 2009 07:15:06 GMT) Full text and rfc822 format available.

Message #8 received at 4146 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Dan Nicolaescu <dann <at> ics.uci.edu>
To: Jamie Lokier <jamie <at> shareable.org>
Cc: 4146 <at> debbugs.gnu.org, emacs-pretest-bug <at> gnu.org
Subject: Re: bug#4146: 23.1.50; c-file-style in buffer local variables does not work!
Date: Sat, 15 Aug 2009 00:10:08 -0700 (PDT)
Jamie Lokier <jamie <at> shareable.org> writes:

  > 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 can confirm this.
This is a regression, it works as expected in emacs-22.3.

IMO this is the type of bad bug that warrants making a dot release as
soon as it's fixed.



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4146; Package emacs. (Sat, 15 Aug 2009 07:20:04 GMT) Full text and rfc822 format available.

Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4146; Package emacs. (Thu, 20 Aug 2009 20:37:20 GMT) Full text and rfc822 format available.

Message #14 received at 4146 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Dan Nicolaescu <dann <at> ics.uci.edu>
To: Jamie Lokier <jamie <at> shareable.org>
Cc: 4146 <at> debbugs.gnu.org
Subject: Re: bug#4146: 23.1.50; c-file-style in buffer local variables does not work!
Date: Wed, 19 Aug 2009 16:15:08 -0700 (PDT)
Jamie Lokier <jamie <at> shareable.org> writes:

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

Please try the emacs-23.1 release, the bug does not occur there.

The snapshot you are using is from the CVS trunk that still has the
bug.  Hopefully it will get fixed there soon.



bug reassigned from package 'emacs' to 'emacs,cc-mode'. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> emacsbugs.donarmstrong.com. (Fri, 21 Aug 2009 01:15:05 GMT) Full text and rfc822 format available.

Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com:
bug#4146; Package emacs,cc-mode. (Thu, 03 Dec 2009 04:55:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Kan-Ru Chen <kanru <at> kanru.info>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com. (Thu, 03 Dec 2009 04:55:06 GMT) Full text and rfc822 format available.

Message #21 received at 4146 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Kan-Ru Chen <kanru <at> kanru.info>
To: 4146 <at> debbugs.gnu.org
Cc: Jamie Lokier <jamie <at> shareable.org>, Dan Nicolaescu <dann <at> ics.uci.edu>
Subject: Re: bug#4146: 23.1.50; c-file-style in buffer local variables does not work!
Date: Thu, 03 Dec 2009 12:46:02 +0800
Dan Nicolaescu <dann <at> ics.uci.edu> writes:

> Please try the emacs-23.1 release, the bug does not occur there.
>
> The snapshot you are using is from the CVS trunk that still has the
> bug.  Hopefully it will get fixed there soon.

Still same here.

,----[ *trace-output* ]
| ======================================================================
| 1 -> c-set-style: stylename="gnu" dont-override=t
| 1 <- c-set-style: nil
| ======================================================================
| 1 -> c-set-style: stylename="bsd" dont-override=t
| 1 <- c-set-style: nil
`----

,----[ emacs-version ]
| GNU Emacs 23.1.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.18.3) of 2009-12-03 on anar
`----

Build from emacs-git EMACS_PRETEST_23_0_95-2741-ge02c08d
-- 
Kan-Ru Chen | http://kanru.info

Q: Why are my replies five sentences or less?
A: http://five.sentenc.es/



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com:
bug#4146; Package emacs,cc-mode. (Thu, 03 Dec 2009 06:05:04 GMT) Full text and rfc822 format available.

Message #24 received at 4146 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Dan Nicolaescu <dann <at> ics.uci.edu>
To: Kan-Ru Chen <kanru <at> kanru.info>
Cc: 4146 <at> debbugs.gnu.org, Jamie Lokier <jamie <at> shareable.org>
Subject: Re: bug#4146: 23.1.50; c-file-style in buffer local variables does not work!
Date: Wed, 2 Dec 2009 21:56:08 -0800 (PST)
Kan-Ru Chen <kanru <at> kanru.info> writes:

  > Dan Nicolaescu <dann <at> ics.uci.edu> writes:
  > 
  > > Please try the emacs-23.1 release, the bug does not occur there.
  > >
  > > The snapshot you are using is from the CVS trunk that still has the
  > > bug.  Hopefully it will get fixed there soon.
  > 
  > Still same here.
  > 
  > ,----[ *trace-output* ]
  > | ======================================================================
  > | 1 -> c-set-style: stylename="gnu" dont-override=t
  > | 1 <- c-set-style: nil
  > | ======================================================================
  > | 1 -> c-set-style: stylename="bsd" dont-override=t
  > | 1 <- c-set-style: nil
  > `----
  > 
  > ,----[ emacs-version ]
  > | GNU Emacs 23.1.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.18.3) of 2009-12-03 on anar
  > `----

Indeed, I can reproduce the problem here with an up to date CVS tree.

It works fine though in the 23.1 release...



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com:
bug#4146; Package emacs,cc-mode. (Fri, 04 Dec 2009 16:20:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Kan-Ru Chen <kanru <at> kanru.info>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com. (Fri, 04 Dec 2009 16:20:03 GMT) Full text and rfc822 format available.

Message #29 received at 4146 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Kan-Ru Chen <kanru <at> kanru.info>
To: emacs-devel <emacs-devel <at> gnu.org>
Cc: bug-cc-mode <bug-cc-mode <at> gnu.org>, 4146 <at> debbugs.gnu.org
Subject: c-file-style in buffer local variables does not work
Date: Sat, 05 Dec 2009 00:10:29 +0800
http://debbugs.gnu.org/4146

Seems introduced by a commit on MAIN branch and later fixed in the
EMACS_23_1_RC branch. But the fix did not merge back to cvs head,
c-file-style is still broken.

-- 
Kan-Ru Chen | http://kanru.info

Q: Why are my replies five sentences or less?
A: http://five.sentenc.es/



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com:
bug#4146; Package emacs,cc-mode. (Sat, 05 Dec 2009 11:30:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Alan Mackenzie <acm <at> muc.de>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com. (Sat, 05 Dec 2009 11:30:05 GMT) Full text and rfc822 format available.

Message #34 received at 4146 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: Kan-Ru Chen <kanru <at> kanru.info>, 4146 <at> debbugs.gnu.org
Cc: emacs-devel <emacs-devel <at> gnu.org>, bug-cc-mode <bug-cc-mode <at> gnu.org>
Subject: Re: bug#4146: c-file-style in buffer local variables does not work
Date: Sat, 5 Dec 2009 11:27:45 +0000
Hi, all,

On Sat, Dec 05, 2009 at 12:10:29AM +0800, Kan-Ru Chen wrote:

> http://debbugs.gnu.org/4146

> Seems introduced by a commit on MAIN branch and later fixed in the
> EMACS_23_1_RC branch. But the fix did not merge back to cvs head,
> c-file-style is still broken.

I have just reverted it in the CVS HEAD.  It should be "OK", now.

> -- 
> Kan-Ru Chen | http://kanru.info

> Q: Why are my replies five sentences or less?
> A: http://five.sentenc.es/

-- 
Alan Mackenzie (Nuremberg, Germany).



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com:
bug#4146; Package emacs,cc-mode. (Sat, 05 Dec 2009 20:25:07 GMT) Full text and rfc822 format available.

Acknowledgement sent to Glenn Morris <rgm <at> gnu.org>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com. (Sat, 05 Dec 2009 20:25:07 GMT) Full text and rfc822 format available.

Message #39 received at 4146 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Alan Mackenzie <acm <at> muc.de>
Cc: Kan-Ru Chen <kanru <at> kanru.info>, 4146 <at> debbugs.gnu.org,
        bug-cc-mode <bug-cc-mode <at> gnu.org>, emacs-devel <at> gnu.org
Subject: Re: bug#4146: c-file-style in buffer local variables does not work
Date: Sat, 05 Dec 2009 15:22:03 -0500
Alan Mackenzie wrote:

> I have just reverted it in the CVS HEAD.  It should be "OK", now.

Looks like you forgot to make a ChangeLog entry.

Also, I guess the issue that you made this change to solve is now
back, though I haven't tested it:

http://lists.gnu.org/archive/html/emacs-devel/2009-07/msg01011.html



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com:
bug#4146; Package emacs,cc-mode. (Sat, 05 Dec 2009 21:00:07 GMT) Full text and rfc822 format available.

Acknowledgement sent to Alan Mackenzie <acm <at> muc.de>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com. (Sat, 05 Dec 2009 21:00:07 GMT) Full text and rfc822 format available.

Message #44 received at 4146 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: Glenn Morris <rgm <at> gnu.org>
Cc: bug-cc-mode <bug-cc-mode <at> gnu.org>, 4146 <at> debbugs.gnu.org,
        Kan-Ru Chen <kanru <at> kanru.info>, emacs-devel <at> gnu.org
Subject: Re: bug#4146: c-file-style in buffer local variables does not work
Date: Sat, 5 Dec 2009 21:00:51 +0000
Hi, Glenn,

On Sat, Dec 05, 2009 at 03:22:03PM -0500, Glenn Morris wrote:

> Alan Mackenzie wrote:

> > I have just reverted it in the CVS HEAD.  It should be "OK", now.

> Looks like you forgot to make a ChangeLog entry.

Yep.  Somehow making that patch felt too easy, as though I'd forgotten
something.  I've done the ChangeLog entry now, thanks for the reminder.

> Also, I guess the issue that you made this change to solve is now
> back, though I haven't tested it:

That's what the quotes round "OK" were alluding to.

> http://lists.gnu.org/archive/html/emacs-devel/2009-07/msg01011.html

Fixing it properly will require a lot of patience, a lot of bloody
mindedness, and a high toleration for mindless tedium.  I'll get round to
it sometime, assuming a fix is possible.  Note that this code is now the
same as what's in 23.1, about which nobody's complained so far.  But yes,
it is a bug.

-- 
Alan Mackenzie (Nuremberg, Germany).



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com:
bug#4146; Package emacs,cc-mode. (Sat, 05 Dec 2009 21:25:06 GMT) Full text and rfc822 format available.

Acknowledgement sent to Glenn Morris <rgm <at> gnu.org>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com. (Sat, 05 Dec 2009 21:25:06 GMT) Full text and rfc822 format available.

Message #49 received at 4146 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Alan Mackenzie <acm <at> muc.de>
Cc: bug-cc-mode <bug-cc-mode <at> gnu.org>, 4146 <at> debbugs.gnu.org,
        Kan-Ru Chen <kanru <at> kanru.info>, emacs-devel <at> gnu.org
Subject: Re: bug#4146: c-file-style in buffer local variables does not work
Date: Sat, 05 Dec 2009 16:22:25 -0500
Alan Mackenzie wrote:

> Fixing it properly will require a lot of patience, a lot of bloody
> mindedness, and a high toleration for mindless tedium.  I'll get round to
> it sometime, assuming a fix is possible. 

cc-mode scares me... The very best of luck to you! :)



bug closed, send any further explanations to Jamie Lokier <jamie <at> shareable.org> Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Wed, 27 Jan 2010 01:53:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <bug-gnu-emacs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 24 Feb 2010 12:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 15 years and 120 days ago.

Previous Next


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