Subject: bug#347: C mode asks twice about local variables

From: Stefan Monnier <[email-masked]>
Date: Tue, 03 Jun 2008 02:40:29 -0400

> Yes.  This needs fixing, somehow.

> The way this happens is that in a C file's local variables list, there
> are two "special" variables, e.g. `c-file-style'.

> When 

>     c-basic-offset: 11
>     c-file-style: "k&r"

> occurs in the local variable list, this triggers a hook function which
> calls (c-set-style "k&r").  The hook is hack-local-variables-hook.  The
> problem is that this c-set-style call will overwrite the explicit value
> for c-basic-offset.  The explicit value MUST take precedence here.

Can you try and call `c-file-style' with some extra "don't override"
(when called from that hack-local-variables-hook) argument so that any
variable that already has a buffer-local binding will not be overridden?

> My solution was to call hack-local-variables a second time from within
> the hook function, first having deleted any occurrences of `mode',
> `c-file-style' etc. from the Local Variables.  This kludge worked
> reasonably well until the handling of safe/dangerous-local-variables was
> changed for Emacs 22.

How 'bout wrapping the call inside (let ((enable-local-variables :safe))?

> If Emacs were not to rebind the do-you-want-to-apply-it variable inside
> hack-local-variables, that would allow the kludge to work.

I don't know what you're referring to here.

        Stefan