emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Blunderbuss ".dir-locals.el" raises everything in its path!!


From: Alan Mackenzie
Subject: Re: Blunderbuss ".dir-locals.el" raises everything in its path!!
Date: Sun, 12 Jul 2009 18:06:23 +0000
User-agent: Mutt/1.5.9i

On Sun, Jul 12, 2009 at 12:39:29PM -0400, Chong Yidong wrote:
> Alan Mackenzie <address@hidden> writes:

> > Surely .dir-locals.el should, in some fashion, supply defaults which
> > may be overridden by mode hooks and the like.  It is almost, but not
> > quite, entirely unlike file local settings, a rarely used precision
> > instrument.

> I'm not sure I understand.  Directory-local variables are processed
> right before file-local variables, and can be overridden by them.

Sorry, yes.  But that's the only thing they can be overridden by.  That
is surely not the right thing.  Consider the variable c-cleanup-list
which Jan though he was setting.  Here is a list of the ways of setting

it (taken from the CC Mode manual, page "Config Basics"), disregarding
for now .dir-locals.el:

    Style
    Top-level command or "customization interface"
    Hook
    File Style
    [Explicit setting in file local variables]

, in increasing order of precedence.  This order seems sensible, IMO.
In particular, the File Style and local variables settings are rarely
used precision instruments, for configuring unusual files unusually.

Now add .dir-locals into the mix:

    Style
    Top-level command or "customization interface"
    Hook
    .dir-locals.el             <=====================
    File Style
    [Explicit setting in file local variables]

Why on earch does .dir-locals.el take precedence over values set in a
top-level `setq' or `c-mode-hook'?  This is surely the Wrong Thing to
do.  Jan hat set his own desired value of c-cleanup-list (as a top-level
command), only to have it obliterated by this line:

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

in .dir-locals.el.

> See `hack-local-variables'---the code merely adds extra variables to
> the file-local-variables-alist, defined in .dir-locals.el files,
> before Emacs adds those defined in the visited file itself.  The local
> variables are then processed in order, wrapped by
> before/after-hack-local-variables-hook.

> Could you try to dig deeper and figure out the problem?

Yes, we both agree on what is happening.  My point is that the contents
of .dir-locals.el should not override explicit values given by the user
in his .emacs.

-- 
Alan Mackenzie (Nuremberg, Germany).




reply via email to

[Prev in Thread] Current Thread [Next in Thread]