mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-12-30 11:09:23 +00:00
Add the ability to exclude dir-locals from subdirs. (Bug#8100)
* lisp/files.el (dir-locals-collect-variables): Add the ability to exclude subdirectories. * doc/emacs/custom.texi (Directory Variables): Give an example of excluding subdirectories. * doc/lispref/variables.texi (Directory Local Variables): Mention `(subdirs . nil)' alist element. * etc/NEWS: Mention this addition. * lisp/dired-x.el (dired-omit-here-always): Add `(subdirs . nil)' to locals.
This commit is contained in:
parent
cead857b3a
commit
6640b281f3
@ -1,3 +1,8 @@
|
||||
2011-03-01 Glenn Morris <rgm@gnu.org>
|
||||
|
||||
* custom.texi (Directory Variables):
|
||||
Give an example of excluding subdirectories.
|
||||
|
||||
2011-02-28 Eli Zaretskii <eliz@gnu.org>
|
||||
|
||||
* search.texi (Regexp Search): Move index entries about regexps to the
|
||||
|
@ -1331,7 +1331,8 @@ corresponding alist applies to all the files in that subdirectory.
|
||||
(tab-width . 4)
|
||||
(fill-column . 80)))
|
||||
(c-mode . ((c-file-style . "BSD")))
|
||||
(java-mode . ((c-file-style . "BSD")))
|
||||
(java-mode . ((c-file-style . "BSD")
|
||||
(subdirs . nil)))
|
||||
("src/imported"
|
||||
. ((nil . ((change-log-default-name . "ChangeLog.local"))))))
|
||||
@end example
|
||||
@ -1340,8 +1341,10 @@ corresponding alist applies to all the files in that subdirectory.
|
||||
This example shows some settings for a hypothetical project. It sets
|
||||
@samp{indent-tabs-mode}, @code{tab-width}, and @code{fill-column} for
|
||||
any file in the project's directory tree, and it sets the indentation
|
||||
style for any C or Java source file. Finally, it specifies a different
|
||||
@file{ChangeLog} file name for any file in the @file{src/imported}
|
||||
style for any C or Java source file. The special @code{subdirs} element
|
||||
indicates that the Java mode settings are only to be applied in the
|
||||
current directory, not in any subdirectories. Finally, it specifies a
|
||||
different @file{ChangeLog} file name for any file in the @file{src/imported}
|
||||
subdirectory of the directory where you put the @file{.dir-locals.el}
|
||||
file.
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
2011-03-01 Glenn Morris <rgm@gnu.org>
|
||||
|
||||
* variables.texi (Directory Local Variables):
|
||||
Mention `(subdirs . nil)' alist element.
|
||||
|
||||
2011-02-28 Glenn Morris <rgm@gnu.org>
|
||||
|
||||
* variables.texi (Directory Local Variables): Mention the optional
|
||||
|
@ -1718,7 +1718,8 @@ directory-local variables. The name of the file is
|
||||
The MS-DOS version of Emacs uses @file{_dir-locals.el} instead, due to
|
||||
limitations of the DOS filesystems.
|
||||
}. A file by that name in a directory causes Emacs to apply its
|
||||
settings to any file in that directory or any of its subdirectories.
|
||||
settings to any file in that directory or any of its subdirectories
|
||||
(optionally, you can exclude subdirectories; see below).
|
||||
If some of the subdirectories have their own @file{.dir-locals.el}
|
||||
files, Emacs uses the settings from the deepest file it finds starting
|
||||
from the file's directory and moving up the directory tree. The file
|
||||
@ -1749,7 +1750,10 @@ file's buffer turns on a mode that is derived from @var{major-mode},
|
||||
then the all the variables in the associated @var{alist} are applied;
|
||||
@var{alist} should be of the form @code{(@var{name} . @var{value})}.
|
||||
A special value @code{nil} for @var{major-mode} means the settings are
|
||||
applicable to any mode.
|
||||
applicable to any mode. In @var{alist}, you can use a special
|
||||
@var{name}: @code{subdirs}. If the associated value is
|
||||
@code{nil}, the alist is only applied to files in the relevant
|
||||
directory, not to those in any subdirectories.
|
||||
|
||||
With the second form of @var{variables}, if @var{directory} is the
|
||||
initial substring of the file's directory, then @var{list} is applied
|
||||
|
5
etc/NEWS
5
etc/NEWS
@ -353,6 +353,11 @@ Just set shell-dir-cookie-re to an appropriate regexp.
|
||||
will turn on `whitespace-mode' for *vc-diff* buffers. Modes should
|
||||
call `hack-dir-local-variables-non-file-buffer' to support this.
|
||||
|
||||
+++
|
||||
** You can prevent directory local variables from applying to subdirectories.
|
||||
Add an element (subdirs . nil) to the alist portion of any variables
|
||||
settings to indicate said section should not be applied to subdirectories.
|
||||
|
||||
** ERC changes
|
||||
|
||||
*** New vars `erc-autojoin-timing' and `erc-autojoin-delay'.
|
||||
|
@ -1,3 +1,10 @@
|
||||
2011-03-01 Glenn Morris <rgm@gnu.org>
|
||||
|
||||
* files.el (dir-locals-collect-variables):
|
||||
Add the ability to exclude subdirectories. (Bug#8100)
|
||||
|
||||
* dired-x.el (dired-omit-here-always): Add `(subdirs . nil)' to locals.
|
||||
|
||||
2011-02-28 Christoph Scholtes <cschol2112@googlemail.com>
|
||||
|
||||
* ido.el (ido-everywhere): Doc fix.
|
||||
|
@ -786,6 +786,7 @@ See also `dired-enable-local-variables'."
|
||||
'hack-dir-local-variables-non-file-buffer "24.1")
|
||||
|
||||
;; Not sure this is worth having a dedicated command for...
|
||||
;; See the more general features in files-x.el.
|
||||
(defun dired-omit-here-always ()
|
||||
"Create `dir-locals-file' setting `dired-omit-mode' to t in `dired-mode'.
|
||||
If in a Dired buffer, reverts it."
|
||||
@ -798,7 +799,9 @@ replace it with a dir-locals-file `./%s'"
|
||||
(if (file-exists-p dir-locals-file)
|
||||
(message "File `./%s' already exists." dir-locals-file)
|
||||
(with-temp-buffer
|
||||
(insert "((dired-mode . ((dired-omit-mode . t))))\n")
|
||||
(insert "\
|
||||
\((dired-mode . ((subdirs . nil)
|
||||
(dired-omit-mode . t))))\n")
|
||||
(write-file dir-locals-file))
|
||||
;; Run extra-hooks and revert directory.
|
||||
(when (derived-mode-p 'dired-mode)
|
||||
|
@ -3394,8 +3394,19 @@ Return the new variables list."
|
||||
(cdr entry) root variables))))
|
||||
((or (not key)
|
||||
(derived-mode-p key))
|
||||
(setq variables (dir-locals-collect-mode-variables
|
||||
(cdr entry) variables))))))
|
||||
(let* ((alist (cdr entry))
|
||||
(subdirs (assq 'subdirs alist)))
|
||||
(if (or (not subdirs)
|
||||
(progn
|
||||
(setq alist (delq subdirs alist))
|
||||
(cdr-safe subdirs))
|
||||
;; TODO someone might want to extent this to allow
|
||||
;; integer values for subdir, where N means
|
||||
;; variables apply to this directory and N levels
|
||||
;; below it (0 == nil).
|
||||
(equal root default-directory))
|
||||
(setq variables (dir-locals-collect-mode-variables
|
||||
alist variables))))))))
|
||||
(error
|
||||
;; The file's content might be invalid (e.g. have a merge conflict), but
|
||||
;; that shouldn't prevent the user from opening the file.
|
||||
|
Loading…
Reference in New Issue
Block a user