unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#4146: 23.1.50; c-file-style in buffer local variables does not work!
@ 2009-08-15  3:41 Jamie Lokier
  2009-08-15  7:10 ` Dan Nicolaescu
  2009-08-19 23:15 ` Dan Nicolaescu
  0 siblings, 2 replies; 5+ messages in thread
From: Jamie Lokier @ 2009-08-15  3:41 UTC (permalink / raw)
  To: emacs-pretest-bug

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





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#4146: 23.1.50; c-file-style in buffer local variables does not work!
  2009-08-15  3:41 bug#4146: 23.1.50; c-file-style in buffer local variables does not work! Jamie Lokier
@ 2009-08-15  7:10 ` Dan Nicolaescu
  2009-08-19 23:15 ` Dan Nicolaescu
  1 sibling, 0 replies; 5+ messages in thread
From: Dan Nicolaescu @ 2009-08-15  7:10 UTC (permalink / raw)
  To: Jamie Lokier; +Cc: emacs-pretest-bug, 4146

Jamie Lokier <jamie@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.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#4146: 23.1.50; c-file-style in buffer local variables does not work!
  2009-08-15  3:41 bug#4146: 23.1.50; c-file-style in buffer local variables does not work! Jamie Lokier
  2009-08-15  7:10 ` Dan Nicolaescu
@ 2009-08-19 23:15 ` Dan Nicolaescu
  1 sibling, 0 replies; 5+ messages in thread
From: Dan Nicolaescu @ 2009-08-19 23:15 UTC (permalink / raw)
  To: Jamie Lokier; +Cc: 4146

Jamie Lokier <jamie@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.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#4146: 23.1.50; c-file-style in buffer local variables does not work!
@ 2009-12-03  4:46 Kan-Ru Chen
  2009-12-03  5:56 ` Dan Nicolaescu
  0 siblings, 1 reply; 5+ messages in thread
From: Kan-Ru Chen @ 2009-12-03  4:46 UTC (permalink / raw)
  To: 4146; +Cc: Dan Nicolaescu, Jamie Lokier


Dan Nicolaescu <dann@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/





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#4146: 23.1.50; c-file-style in buffer local variables does not work!
  2009-12-03  4:46 Kan-Ru Chen
@ 2009-12-03  5:56 ` Dan Nicolaescu
  0 siblings, 0 replies; 5+ messages in thread
From: Dan Nicolaescu @ 2009-12-03  5:56 UTC (permalink / raw)
  To: Kan-Ru Chen; +Cc: 4146, Jamie Lokier

Kan-Ru Chen <kanru@kanru.info> writes:

  > Dan Nicolaescu <dann@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...





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-12-03  5:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-15  3:41 bug#4146: 23.1.50; c-file-style in buffer local variables does not work! Jamie Lokier
2009-08-15  7:10 ` Dan Nicolaescu
2009-08-19 23:15 ` Dan Nicolaescu
  -- strict thread matches above, loose matches on Subject: below --
2009-12-03  4:46 Kan-Ru Chen
2009-12-03  5:56 ` Dan Nicolaescu

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).