changeset 103982:bffadf81bdd5

(ignored-local-variables): Add `dir-local-variables-alist'. (dir-local-variables-alist): New buffer-local variable. (hack-local-variables-filter): If variable is not dir-local, i.e. `dir-name' is nil, then remove it from `dir-local-variables-alist', because file-local overrides dir-local. (c-postprocess-file-styles)<declare-function>: Remove obsolete declaration. (hack-dir-local-variables): Add dir-local variable/value pair to `dir-local-variables-alist' and remove duplicates. Doc fix.
author Juri Linkov <juri@jurta.org>
date Sun, 19 Jul 2009 16:55:16 +0000
parents 79bd2c1abfc5
children 4af91568dcc6
files lisp/files.el
diffstat 1 files changed, 20 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/files.el	Sun Jul 19 01:05:17 2009 +0000
+++ b/lisp/files.el	Sun Jul 19 16:55:16 2009 +0000
@@ -2637,7 +2637,7 @@
 
 (defvar ignored-local-variables
   '(ignored-local-variables safe-local-variable-values
-    file-local-variables-alist)
+    file-local-variables-alist dir-local-variables-alist)
   "Variables to be ignored in a file's local variable spec.")
 
 (defvar hack-local-variables-hook nil
@@ -2760,6 +2760,15 @@
 if it is changed by the major or minor modes, or by the user.")
 (make-variable-buffer-local 'file-local-variables-alist)
 
+(defvar dir-local-variables-alist nil
+  "Alist of directory-local variable settings in the current buffer.
+Each element in this list has the form (VAR . VALUE), where VAR
+is a directory-local variable (a symbol) and VALUE is the value
+specified in .dir-locals.el.  The actual value in the buffer
+may differ from VALUE, if it is changed by the major or minor modes,
+or by the user.")
+(make-variable-buffer-local 'dir-local-variables-alist)
+
 (defvar before-hack-local-variables-hook nil
   "Normal hook run before setting file-local variables.
 It is called after checking for unsafe/risky variables and
@@ -2969,6 +2978,9 @@
 					   risky-vars dir-name))
 	 (dolist (elt all-vars)
 	   (unless (eq (car elt) 'eval)
+	     (unless dir-name
+	       (setq dir-local-variables-alist
+		     (assq-delete-all (car elt) dir-local-variables-alist)))
 	     (setq file-local-variables-alist
 		   (assq-delete-all (car elt) file-local-variables-alist)))
 	   (push elt file-local-variables-alist)))))
@@ -3364,12 +3376,10 @@
 				      (nth 5 (file-attributes file)))
       class-name)))
 
-(declare-function c-postprocess-file-styles "cc-mode" ())
-
 (defun hack-dir-local-variables ()
   "Read per-directory local variables for the current buffer.
-Store the directory-local variables in `file-local-variables-alist',
-without applying them."
+Store the directory-local variables in `dir-local-variables-alist'
+and `file-local-variables-alist', without applying them."
   (when (and enable-local-variables
 	     (buffer-file-name)
 	     (not (file-remote-p (buffer-file-name))))
@@ -3389,6 +3399,11 @@
 	       (dir-locals-collect-variables
 		(dir-locals-get-class-variables class) dir-name nil)))
 	  (when variables
+	    (dolist (elt variables)
+	      (unless (eq (car elt) 'eval)
+		(setq dir-local-variables-alist
+		      (assq-delete-all (car elt) dir-local-variables-alist)))
+	      (push elt dir-local-variables-alist))
 	    (hack-local-variables-filter variables dir-name)))))))