Subject: Re: bug#17489: 24.3; Major mode spec in .dir-locals.el breaks dired

From: Sergio Pokrovskij <[email-masked]>
Date: Thu, 15 May 2014 00:24:47 +0700

>>>>> "Eli" == Eli Zaretskii wrote:

[...]

  Eli> It's not clear what did you expect instead.  Did you expect
  Eli> that unconditionally turning on some mode in a Dired buffer
  Eli> be ignored, just because it's a Dired buffer?

Kind of.  It is not quite a "local file".  Cf:

,----
| Sometimes, you may wish to define the same set of local variables
| to all the files in a certain directory ...
`---- (info "(emacs)Directory Variables")

  Eli> Or did you expect that your .dir-locals.el settings be in
  Eli> effect only for files, not for directories?

This too, normally "local variables" are not attributable to
directories, are they?

  Eli> Or did you expect that cc-mode somehow gracefully does
  Eli> nothing when the buffer text is not a C-like program
  Eli> source?

It seems that it's a dired's problem rather than cc-mode's.

  Eli> Or something else?

My expectation was that I could specify a local-variable setting
common to all the files from the directory in question.  And
actually it does work.  The only problem is that it breaks the
dired buffer.

  Eli> IOW, why isn't that .dir-locals.el setting of yours not a
  Eli> cockpit error?

Because there is no appropriate means to impose a reasonable
condition.  Just the "nil" or a major mode name.  It may happen
that I do not know the a-priori mode; actually it is mode that I
would like to set.

After all, I've found a workaround; but I believe the feature
would be more useful if it could be restricted to '-' files only
(i.e. only to those which normally can contain
"Local variables:"):

,----
| Whenever Emacs visits any file IN THAT DIRECTORY or any of its
| subdirectories, it will apply the directory-local variables
| specified in `.dir-locals.el', AS THOUGH THEY HAD BEEN DEFINED AS
| FILE-LOCAL VARIABLES for that file ...
`----

-- 
Sergio