[Top][All Lists]
[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 21:21:03 +0000 |
User-agent: |
Mutt/1.5.9i |
Hi, Yidong!
On Sun, Jul 12, 2009 at 02:37:05PM -0400, Chong Yidong wrote:
> Alan Mackenzie <address@hidden> writes:
> >> 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.
> > Why on earth 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.
> Because setting a directory-local variable is supposed to have the same
> effect as setting a file-local variable inside every file in that
> directory. Thus, instead of putting c-fill-style inside every .c file
> in the Emacs source tree, you can simply write a .dir-locals.el file.
> > In particular, the File Style and local variables settings are rarely
> > used precision instruments, for configuring unusual files unusually.
> This indicates that we should not set c-file-style in the .dir-locals.el
> file of the Emacs source tree.
That's fine by me! As well as amending that file, I've juiced up the doc
strings in the two pertinent CC Mode variables, and put some stuff into
the Emacs and Elisp manuals.
I'd be grateful for somebody checking my prose.
Incidentally, I've expanded the inane sentence that says that (project)
files are kept in directories. I think most people knew that already.
;-)
Index: .dir-locals.el
===================================================================
RCS file: /cvsroot/emacs/emacs/.dir-locals.el,v
retrieving revision 1.6
diff -c -r1.6 .dir-locals.el
*** .dir-locals.el 14 Jan 2009 23:16:12 -0000 1.6
--- .dir-locals.el 12 Jul 2009 21:09:42 -0000
***************
*** 1,6 ****
((nil . ((tab-width . 8)
(fill-column . 70)))
- (c-mode . ((c-file-style . "GNU")))
(change-log-mode . ((add-log-time-zone-rule . t)
(fill-column . 74)
(bug-reference-url-format
--- 1,5 ----
Index: doc/emacs/custom.texi
===================================================================
RCS file: /cvsroot/emacs/emacs/doc/emacs/custom.texi,v
retrieving revision 1.22
diff -c -r1.22 custom.texi
*** doc/emacs/custom.texi 4 Jun 2009 03:13:28 -0000 1.22
--- doc/emacs/custom.texi 12 Jul 2009 21:09:44 -0000
***************
*** 1267,1279 ****
@cindex per-directory local variables
A @dfn{project} is a collection of files on which you work together.
! Usually, the project's files are kept in one or more directories.
! Occasionally, you may wish to define Emacs settings that are common to
! all the files that belong to the project.
Emacs provides two ways to specify settings that are applicable to
files in a specific directory: you can put a special file in that
! directory, or you can define a @dfn{project class} for that directory.
@cindex @file{.dir-locals.el} file
If you put a file with a special name @address@hidden
--- 1267,1288 ----
@cindex per-directory local variables
A @dfn{project} is a collection of files on which you work together.
! Usually, the project's files are kept in one or more directories of
! their own. Occasionally, you may wish to define Emacs settings that
! are common to all the files that belong to the project.
Emacs provides two ways to specify settings that are applicable to
files in a specific directory: you can put a special file in that
! directory, or you can define a @dfn{project class} for that
! directory.
!
! Note that Emacs applies these settings for each file it loads, after
! having initialized the file's major mode and run the mode hook. These
! settings can override those made by a user in his .emacs, possibly in
! a mode hook, so you should be careful not to set variables which are a
! matter of personal choice. You should probably not set
! @code{c-file-syle} and @code{c-file-offsets} here (@pxref{File
! Styles,,,ccmode}).
@cindex @file{.dir-locals.el} file
If you put a file with a special name @address@hidden
***************
*** 1302,1309 ****
((nil . ((indent-tabs-mode . t)
(tab-width . 4)
(fill-column . 80)))
- (c-mode . ((c-file-style . "BSD")))
- (java-mode . ((c-file-style . "BSD")))
("src/imported"
. ((nil . ((change-log-default-name . "ChangeLog.local"))))))
@end example
--- 1311,1316 ----
Index: doc/lispref/variables.texi
===================================================================
RCS file: /cvsroot/emacs/emacs/doc/lispref/variables.texi,v
retrieving revision 1.19
diff -c -r1.19 variables.texi
*** doc/lispref/variables.texi 17 Jun 2009 02:58:57 -0000 1.19
--- doc/lispref/variables.texi 12 Jul 2009 21:09:53 -0000
***************
*** 1703,1708 ****
--- 1703,1716 ----
variables: by putting them in a special file, or by defining a
@dfn{project class} for that directory.
+ Note that Emacs applies these settings for each file it loads, after
+ having initialized the file's major mode and run the mode hook
+ (@pxref{Mode Hooks}). These settings can override those made by a
+ user in his .emacs, possibly in a mode hook, so you should be careful
+ not to set variables which are a matter of personal choice. You
+ should probably not set @code{c-file-syle} and @code{c-file-offsets}
+ here (@pxref{File Styles,,,ccmode}).
+
@defvr Constant dir-locals-file
This constant is the name of the file where Emacs expects to find the
directory-local variables. The name of the file is
Index: lisp/progmodes/cc-vars.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/cc-vars.el,v
retrieving revision 1.73
diff -c -r1.73 cc-vars.el
*** lisp/progmodes/cc-vars.el 30 Apr 2009 10:36:24 -0000 1.73
--- lisp/progmodes/cc-vars.el 12 Jul 2009 21:09:55 -0000
***************
*** 1608,1613 ****
--- 1608,1618 ----
string suitable for `c-set-style'. When the file is visited, CC Mode
will set the style of the file to this value automatically.
+ Don't use this variable anywhere but a file's Local Variable section.
+ You probably don't want to use this in a .dir-locals.el file, since
+ this would nullify any explicit settings of style variables at the
+ top level or in hooks.
+
Note that file style settings are applied before file offset settings
as designated in the variable `c-file-offsets'.")
(make-variable-buffer-local 'c-file-style)
***************
*** 1620,1625 ****
--- 1625,1635 ----
When the file is visited, CC Mode will institute these offset settings
automatically.
+ Don't use this variable anywhere but a file's Local Variable section.
+ You probably don't want to use this in a .dir-locals.el file, since
+ this would nullify any explicit settings of style variables at the
+ top level or in hooks.
+
Note that file offset settings are applied after file style settings
as designated in the variable `c-file-style'.")
(make-variable-buffer-local 'c-file-offsets)
Goodnight!
--
Alan Mackenzie (Nuremberg, Germany).
- Re: Add file-locals and dir-locals, (continued)
- Re: Add file-locals and dir-locals, martin rudalics, 2009/07/18
- Re: Add file-locals and dir-locals, Juri Linkov, 2009/07/18
- Re: Add file-locals and dir-locals, martin rudalics, 2009/07/19
- Re: Add file-locals and dir-locals, Juri Linkov, 2009/07/19
- Re: Add file-locals and dir-locals, Leo, 2009/07/20
- Re: Add file-locals and dir-locals, Juri Linkov, 2009/07/21
- Re: Add file-locals and dir-locals, Leo, 2009/07/21
- Re: Add file-locals and dir-locals, David Kastrup, 2009/07/17
- Re: Add file-locals and dir-locals, Juri Linkov, 2009/07/17
- Re: Blunderbuss ".dir-locals.el" raises everything in its path!!, Chong Yidong, 2009/07/12
- Re: Blunderbuss ".dir-locals.el" raises everything in its path!!,
Alan Mackenzie <=
- Re: Blunderbuss ".dir-locals.el" raises everything in its path!!, Lennart Borgman, 2009/07/12
- Re: Blunderbuss ".dir-locals.el" raises everything in its path!!, Alan Mackenzie, 2009/07/12
- Re: Blunderbuss ".dir-locals.el" raises everything in its path!!, Lennart Borgman, 2009/07/12
- Re: Blunderbuss ".dir-locals.el" raises everything in its path!!, Stephen J. Turnbull, 2009/07/12
- Re: Blunderbuss ".dir-locals.el" raises everything in its path!!, Lennart Borgman, 2009/07/12
- Re: Blunderbuss ".dir-locals.el" raises everything in its path!!, tomas, 2009/07/13
- Re: Blunderbuss ".dir-locals.el" raises everything in its path!!, Giorgos Keramidas, 2009/07/12
- Re: Blunderbuss ".dir-locals.el" raises everything in its path!!, Alan Mackenzie, 2009/07/13
- Re: Blunderbuss ".dir-locals.el" raises everything in its path!!, Chong Yidong, 2009/07/13
- Re: Blunderbuss ".dir-locals.el" raises everything in its path!!, Miles Bader, 2009/07/13