emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r103455: Add the ability to exclude d


From: Glenn Morris
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r103455: Add the ability to exclude dir-locals from subdirs. (Bug#8100)
Date: Mon, 28 Feb 2011 19:05:28 -0800
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 103455
committer: Glenn Morris <address@hidden>
branch nick: trunk
timestamp: Mon 2011-02-28 19:05:28 -0800
message:
  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.
modified:
  doc/emacs/ChangeLog
  doc/emacs/custom.texi
  doc/lispref/ChangeLog
  doc/lispref/variables.texi
  etc/NEWS
  lisp/ChangeLog
  lisp/dired-x.el
  lisp/files.el
=== modified file 'doc/emacs/ChangeLog'
--- a/doc/emacs/ChangeLog       2011-02-28 01:07:29 +0000
+++ b/doc/emacs/ChangeLog       2011-03-01 03:05:28 +0000
@@ -1,3 +1,8 @@
+2011-03-01  Glenn Morris  <address@hidden>
+
+       * custom.texi (Directory Variables):
+       Give an example of excluding subdirectories.
+
 2011-02-28  Eli Zaretskii  <address@hidden>
 
        * search.texi (Regexp Search): Move index entries about regexps to the

=== modified file 'doc/emacs/custom.texi'
--- a/doc/emacs/custom.texi     2011-02-05 22:30:14 +0000
+++ b/doc/emacs/custom.texi     2011-03-01 03:05:28 +0000
@@ -1331,7 +1331,8 @@
          (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 @@
 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
address@hidden 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.
 

=== modified file 'doc/lispref/ChangeLog'
--- a/doc/lispref/ChangeLog     2011-02-28 01:07:29 +0000
+++ b/doc/lispref/ChangeLog     2011-03-01 03:05:28 +0000
@@ -1,3 +1,8 @@
+2011-03-01  Glenn Morris  <address@hidden>
+
+       * variables.texi (Directory Local Variables):
+       Mention `(subdirs . nil)' alist element.
+
 2011-02-28  Glenn Morris  <address@hidden>
 
        * variables.texi (Directory Local Variables): Mention the optional

=== modified file 'doc/lispref/variables.texi'
--- a/doc/lispref/variables.texi        2011-02-28 01:07:29 +0000
+++ b/doc/lispref/variables.texi        2011-03-01 03:05:28 +0000
@@ -1718,7 +1718,8 @@
 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 @@
 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
address@hidden: @code{subdirs}.  If the associated value is
address@hidden, 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

=== modified file 'etc/NEWS'
--- a/etc/NEWS  2011-02-23 15:22:28 +0000
+++ b/etc/NEWS  2011-03-01 03:05:28 +0000
@@ -353,6 +353,11 @@
 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'.

=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2011-02-28 20:25:50 +0000
+++ b/lisp/ChangeLog    2011-03-01 03:05:28 +0000
@@ -1,3 +1,10 @@
+2011-03-01  Glenn Morris  <address@hidden>
+
+       * 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  <address@hidden>
 
        * ido.el (ido-everywhere): Doc fix.

=== modified file 'lisp/dired-x.el'
--- a/lisp/dired-x.el   2011-02-28 17:42:03 +0000
+++ b/lisp/dired-x.el   2011-03-01 03:05:28 +0000
@@ -786,6 +786,7 @@
                '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 @@
   (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)

=== modified file 'lisp/files.el'
--- a/lisp/files.el     2011-02-24 08:02:45 +0000
+++ b/lisp/files.el     2011-03-01 03:05:28 +0000
@@ -3394,8 +3394,19 @@
                                  (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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]