diff options
| author | Glenn Morris | 2011-02-28 19:05:28 -0800 |
|---|---|---|
| committer | Glenn Morris | 2011-02-28 19:05:28 -0800 |
| commit | 6640b281f372aebe09d0e323b79a9aa7c311fcc2 (patch) | |
| tree | f18250d5164ee22f85af3d5668ece566de9871ff | |
| parent | cead857b3afcf0ed0166f397cb69c478a6c368f6 (diff) | |
| download | emacs-6640b281f372aebe09d0e323b79a9aa7c311fcc2.tar.gz emacs-6640b281f372aebe09d0e323b79a9aa7c311fcc2.zip | |
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.
| -rw-r--r-- | doc/emacs/ChangeLog | 5 | ||||
| -rw-r--r-- | doc/emacs/custom.texi | 9 | ||||
| -rw-r--r-- | doc/lispref/ChangeLog | 5 | ||||
| -rw-r--r-- | doc/lispref/variables.texi | 8 | ||||
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/dired-x.el | 5 | ||||
| -rw-r--r-- | lisp/files.el | 15 |
8 files changed, 51 insertions, 8 deletions
diff --git a/doc/emacs/ChangeLog b/doc/emacs/ChangeLog index 7a9c3ae3a47..8b94bf8f6dd 100644 --- a/doc/emacs/ChangeLog +++ b/doc/emacs/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2011-03-01 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * custom.texi (Directory Variables): | ||
| 4 | Give an example of excluding subdirectories. | ||
| 5 | |||
| 1 | 2011-02-28 Eli Zaretskii <eliz@gnu.org> | 6 | 2011-02-28 Eli Zaretskii <eliz@gnu.org> |
| 2 | 7 | ||
| 3 | * search.texi (Regexp Search): Move index entries about regexps to the | 8 | * search.texi (Regexp Search): Move index entries about regexps to the |
diff --git a/doc/emacs/custom.texi b/doc/emacs/custom.texi index dfd55b13f18..9304e8bef08 100644 --- a/doc/emacs/custom.texi +++ b/doc/emacs/custom.texi | |||
| @@ -1331,7 +1331,8 @@ corresponding alist applies to all the files in that subdirectory. | |||
| 1331 | (tab-width . 4) | 1331 | (tab-width . 4) |
| 1332 | (fill-column . 80))) | 1332 | (fill-column . 80))) |
| 1333 | (c-mode . ((c-file-style . "BSD"))) | 1333 | (c-mode . ((c-file-style . "BSD"))) |
| 1334 | (java-mode . ((c-file-style . "BSD"))) | 1334 | (java-mode . ((c-file-style . "BSD") |
| 1335 | (subdirs . nil))) | ||
| 1335 | ("src/imported" | 1336 | ("src/imported" |
| 1336 | . ((nil . ((change-log-default-name . "ChangeLog.local")))))) | 1337 | . ((nil . ((change-log-default-name . "ChangeLog.local")))))) |
| 1337 | @end example | 1338 | @end example |
| @@ -1340,8 +1341,10 @@ corresponding alist applies to all the files in that subdirectory. | |||
| 1340 | This example shows some settings for a hypothetical project. It sets | 1341 | This example shows some settings for a hypothetical project. It sets |
| 1341 | @samp{indent-tabs-mode}, @code{tab-width}, and @code{fill-column} for | 1342 | @samp{indent-tabs-mode}, @code{tab-width}, and @code{fill-column} for |
| 1342 | any file in the project's directory tree, and it sets the indentation | 1343 | any file in the project's directory tree, and it sets the indentation |
| 1343 | style for any C or Java source file. Finally, it specifies a different | 1344 | style for any C or Java source file. The special @code{subdirs} element |
| 1344 | @file{ChangeLog} file name for any file in the @file{src/imported} | 1345 | indicates that the Java mode settings are only to be applied in the |
| 1346 | current directory, not in any subdirectories. Finally, it specifies a | ||
| 1347 | different @file{ChangeLog} file name for any file in the @file{src/imported} | ||
| 1345 | subdirectory of the directory where you put the @file{.dir-locals.el} | 1348 | subdirectory of the directory where you put the @file{.dir-locals.el} |
| 1346 | file. | 1349 | file. |
| 1347 | 1350 | ||
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index c8925715f74..1a980f14f3d 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2011-03-01 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * variables.texi (Directory Local Variables): | ||
| 4 | Mention `(subdirs . nil)' alist element. | ||
| 5 | |||
| 1 | 2011-02-28 Glenn Morris <rgm@gnu.org> | 6 | 2011-02-28 Glenn Morris <rgm@gnu.org> |
| 2 | 7 | ||
| 3 | * variables.texi (Directory Local Variables): Mention the optional | 8 | * variables.texi (Directory Local Variables): Mention the optional |
diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi index c6af304416c..a68b2b6dd4e 100644 --- a/doc/lispref/variables.texi +++ b/doc/lispref/variables.texi | |||
| @@ -1718,7 +1718,8 @@ directory-local variables. The name of the file is | |||
| 1718 | The MS-DOS version of Emacs uses @file{_dir-locals.el} instead, due to | 1718 | The MS-DOS version of Emacs uses @file{_dir-locals.el} instead, due to |
| 1719 | limitations of the DOS filesystems. | 1719 | limitations of the DOS filesystems. |
| 1720 | }. A file by that name in a directory causes Emacs to apply its | 1720 | }. A file by that name in a directory causes Emacs to apply its |
| 1721 | settings to any file in that directory or any of its subdirectories. | 1721 | settings to any file in that directory or any of its subdirectories |
| 1722 | (optionally, you can exclude subdirectories; see below). | ||
| 1722 | If some of the subdirectories have their own @file{.dir-locals.el} | 1723 | If some of the subdirectories have their own @file{.dir-locals.el} |
| 1723 | files, Emacs uses the settings from the deepest file it finds starting | 1724 | files, Emacs uses the settings from the deepest file it finds starting |
| 1724 | from the file's directory and moving up the directory tree. The file | 1725 | 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}, | |||
| 1749 | then the all the variables in the associated @var{alist} are applied; | 1750 | then the all the variables in the associated @var{alist} are applied; |
| 1750 | @var{alist} should be of the form @code{(@var{name} . @var{value})}. | 1751 | @var{alist} should be of the form @code{(@var{name} . @var{value})}. |
| 1751 | A special value @code{nil} for @var{major-mode} means the settings are | 1752 | A special value @code{nil} for @var{major-mode} means the settings are |
| 1752 | applicable to any mode. | 1753 | applicable to any mode. In @var{alist}, you can use a special |
| 1754 | @var{name}: @code{subdirs}. If the associated value is | ||
| 1755 | @code{nil}, the alist is only applied to files in the relevant | ||
| 1756 | directory, not to those in any subdirectories. | ||
| 1753 | 1757 | ||
| 1754 | With the second form of @var{variables}, if @var{directory} is the | 1758 | With the second form of @var{variables}, if @var{directory} is the |
| 1755 | initial substring of the file's directory, then @var{list} is applied | 1759 | initial substring of the file's directory, then @var{list} is applied |
| @@ -353,6 +353,11 @@ Just set shell-dir-cookie-re to an appropriate regexp. | |||
| 353 | will turn on `whitespace-mode' for *vc-diff* buffers. Modes should | 353 | will turn on `whitespace-mode' for *vc-diff* buffers. Modes should |
| 354 | call `hack-dir-local-variables-non-file-buffer' to support this. | 354 | call `hack-dir-local-variables-non-file-buffer' to support this. |
| 355 | 355 | ||
| 356 | +++ | ||
| 357 | ** You can prevent directory local variables from applying to subdirectories. | ||
| 358 | Add an element (subdirs . nil) to the alist portion of any variables | ||
| 359 | settings to indicate said section should not be applied to subdirectories. | ||
| 360 | |||
| 356 | ** ERC changes | 361 | ** ERC changes |
| 357 | 362 | ||
| 358 | *** New vars `erc-autojoin-timing' and `erc-autojoin-delay'. | 363 | *** New vars `erc-autojoin-timing' and `erc-autojoin-delay'. |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e5abd0b93d7..5b8a5be8280 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2011-03-01 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * files.el (dir-locals-collect-variables): | ||
| 4 | Add the ability to exclude subdirectories. (Bug#8100) | ||
| 5 | |||
| 6 | * dired-x.el (dired-omit-here-always): Add `(subdirs . nil)' to locals. | ||
| 7 | |||
| 1 | 2011-02-28 Christoph Scholtes <cschol2112@googlemail.com> | 8 | 2011-02-28 Christoph Scholtes <cschol2112@googlemail.com> |
| 2 | 9 | ||
| 3 | * ido.el (ido-everywhere): Doc fix. | 10 | * ido.el (ido-everywhere): Doc fix. |
diff --git a/lisp/dired-x.el b/lisp/dired-x.el index 816beb0034c..9941c7a0db5 100644 --- a/lisp/dired-x.el +++ b/lisp/dired-x.el | |||
| @@ -786,6 +786,7 @@ See also `dired-enable-local-variables'." | |||
| 786 | 'hack-dir-local-variables-non-file-buffer "24.1") | 786 | 'hack-dir-local-variables-non-file-buffer "24.1") |
| 787 | 787 | ||
| 788 | ;; Not sure this is worth having a dedicated command for... | 788 | ;; Not sure this is worth having a dedicated command for... |
| 789 | ;; See the more general features in files-x.el. | ||
| 789 | (defun dired-omit-here-always () | 790 | (defun dired-omit-here-always () |
| 790 | "Create `dir-locals-file' setting `dired-omit-mode' to t in `dired-mode'. | 791 | "Create `dir-locals-file' setting `dired-omit-mode' to t in `dired-mode'. |
| 791 | If in a Dired buffer, reverts it." | 792 | If in a Dired buffer, reverts it." |
| @@ -798,7 +799,9 @@ replace it with a dir-locals-file `./%s'" | |||
| 798 | (if (file-exists-p dir-locals-file) | 799 | (if (file-exists-p dir-locals-file) |
| 799 | (message "File `./%s' already exists." dir-locals-file) | 800 | (message "File `./%s' already exists." dir-locals-file) |
| 800 | (with-temp-buffer | 801 | (with-temp-buffer |
| 801 | (insert "((dired-mode . ((dired-omit-mode . t))))\n") | 802 | (insert "\ |
| 803 | \((dired-mode . ((subdirs . nil) | ||
| 804 | (dired-omit-mode . t))))\n") | ||
| 802 | (write-file dir-locals-file)) | 805 | (write-file dir-locals-file)) |
| 803 | ;; Run extra-hooks and revert directory. | 806 | ;; Run extra-hooks and revert directory. |
| 804 | (when (derived-mode-p 'dired-mode) | 807 | (when (derived-mode-p 'dired-mode) |
diff --git a/lisp/files.el b/lisp/files.el index 5890bf9b8c9..bafae814756 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -3394,8 +3394,19 @@ Return the new variables list." | |||
| 3394 | (cdr entry) root variables)))) | 3394 | (cdr entry) root variables)))) |
| 3395 | ((or (not key) | 3395 | ((or (not key) |
| 3396 | (derived-mode-p key)) | 3396 | (derived-mode-p key)) |
| 3397 | (setq variables (dir-locals-collect-mode-variables | 3397 | (let* ((alist (cdr entry)) |
| 3398 | (cdr entry) variables)))))) | 3398 | (subdirs (assq 'subdirs alist))) |
| 3399 | (if (or (not subdirs) | ||
| 3400 | (progn | ||
| 3401 | (setq alist (delq subdirs alist)) | ||
| 3402 | (cdr-safe subdirs)) | ||
| 3403 | ;; TODO someone might want to extent this to allow | ||
| 3404 | ;; integer values for subdir, where N means | ||
| 3405 | ;; variables apply to this directory and N levels | ||
| 3406 | ;; below it (0 == nil). | ||
| 3407 | (equal root default-directory)) | ||
| 3408 | (setq variables (dir-locals-collect-mode-variables | ||
| 3409 | alist variables)))))))) | ||
| 3399 | (error | 3410 | (error |
| 3400 | ;; The file's content might be invalid (e.g. have a merge conflict), but | 3411 | ;; The file's content might be invalid (e.g. have a merge conflict), but |
| 3401 | ;; that shouldn't prevent the user from opening the file. | 3412 | ;; that shouldn't prevent the user from opening the file. |