aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorGlenn Morris2011-02-28 19:05:28 -0800
committerGlenn Morris2011-02-28 19:05:28 -0800
commit6640b281f372aebe09d0e323b79a9aa7c311fcc2 (patch)
treef18250d5164ee22f85af3d5668ece566de9871ff /lisp
parentcead857b3afcf0ed0166f397cb69c478a6c368f6 (diff)
downloademacs-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.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/dired-x.el5
-rw-r--r--lisp/files.el15
3 files changed, 24 insertions, 3 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index e5abd0b93d7..5b8a5be8280 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
12011-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
12011-02-28 Christoph Scholtes <cschol2112@googlemail.com> 82011-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'.
791If in a Dired buffer, reverts it." 792If 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.