Subject: bug#8251: c-default-style vs. .dir-locals

From: Juanma Barranquero <[email-masked]>
Date: Mon, 14 Mar 2011 21:50:25 +0100

Package: emacs
Version: 24.0.50

The test file contains just three lines:

{
  x;
}

(there are two spaces before "x;", as per the GNU style)

and .dir-locals.el is a one-liner:

((c-mode . ((c-file-style . "GNU"))))

Cases:

1.- No .dir-locals.el, no c-default-style

    rm .dir-locals.el
    emacs -Q test.c

    then c-indentation-style == "gnu", c-basic-offset == 2 (original
value was set-from-style; local in buffer test.c; global value is
set-from-style). And indeed, C-n <TAB> does not change anything.

2.- No .dir-locals, set c-default-style

    rm .dir-locals.el
    emacs -Q --eval '(setq c-default-style '((other . "stroustrup")))' test.c

    then c-indentation-style == "stroustrup", c-basic-offset == 4, and
C-n <TAB> reindents the x; line.

3.- .dir-locals.el, set c-default-style

    echo ((c-mode . ((c-file-style . "GNU"))))> .dir-locals.el
    emacs -Q --eval '(setq c-default-style '((other . "stroustrup")))' test.c

    then c-indentation-style == "gnu", c-basic-offset == 4, and C-n
<TAB> reindents.

4.- Like 3, but manually setting the style

    echo ((c-mode . ((c-file-style . "GNU"))))> .dir-locals.el
    emacs -Q --eval '(setq c-default-style '((other . "stroustrup")))' test.c
    C-c . gnu <RET>

    then c-indentation-style == "gnu", c-basic-offset == 2, and C-n
<TAB> does nothing (as expected).

Shouldn't case 3 work as 4? Or am I misunderstanding something obvious?

    Juanma