From 97a1cd9d27e7d95263b475d03ce39c20a2ff4512 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Sun, 10 Feb 2013 17:50:45 -0800 Subject: [PATCH] Add `enable-dir-local-variables' * lisp/files.el (enable-dir-local-variables): New variable. (hack-dir-local-variables): Respect enable-dir-local-variables. * lisp/tutorial.el (help-with-tutorial): Ignore directory-local variables. Fixes: debbugs:11127 --- etc/NEWS | 8 ++++++-- lisp/ChangeLog | 5 +++++ lisp/files.el | 11 ++++++++++- lisp/tutorial.el | 10 ++++------ 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 2d1f4566123..4525d705183 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -45,6 +45,10 @@ non-nil, they output the same results. ** `eval-defun' on an already defined defcustom calls the :set function, if there is one. +** If the new variable `enable-dir-local-variables' is nil, +directory local variables are ignored. May be useful for some modes +that want to ignore directory-locals while still respecting file-locals. + ** The option `set-mark-default-inactive' has been deleted. This unfinished feature was introduced by accident in Emacs 23.1; simply disabling Transient Mark mode does the same thing. @@ -228,7 +232,7 @@ alist of extended attributes as returned by the new function file using `set-file-extended-attributes'. -* Lisp changes in Emacs 24.4 +* Lisp Changes in Emacs 24.4 ** Support for filesystem notifications. Emacs now supports notifications of filesystem changes, such as @@ -273,7 +277,7 @@ used in place of the 9th element of `file-attributes'. and ACL entries. -* Changes in Emacs 24.4 on non-free operating systems +* Changes in Emacs 24.4 on Non-Free Operating Systems +++ ** The "generate a backtrace on fatal error" feature now works on MS Windows. diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5b80c1dbdbe..979c0808b7b 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,10 @@ 2013-02-11 Glenn Morris + * files.el (enable-dir-local-variables): New variable. + (hack-dir-local-variables): Respect enable-dir-local-variables. + * tutorial.el (help-with-tutorial): + Ignore directory-local variables. (Bug#11127) + * vc/vc-svn.el (vc-svn-command): Move --non-interactive from here... (vc-svn-global-switches): ... to here. (Bug#13513) diff --git a/lisp/files.el b/lisp/files.el index c9e5d2763fe..890834d4af0 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -507,6 +507,11 @@ and ignores this variable." (other :tag "Query" other)) :group 'find-file) +(defvar enable-dir-local-variables t + "Non-nil means enable use of directory-local variables. +Some modes may wish to set this to nil to prevent directory-local +settings being applied, but still respect file-local ones.") + ;; This is an odd variable IMO. ;; You might wonder why it is needed, when we could just do: ;; (set (make-local-variable 'enable-local-variables) nil) @@ -3659,8 +3664,12 @@ is found. Returns the new class name." (defun hack-dir-local-variables () "Read per-directory local variables for the current buffer. Store the directory-local variables in `dir-local-variables-alist' -and `file-local-variables-alist', without applying them." +and `file-local-variables-alist', without applying them. + +This does nothing if either `enable-local-variables' or +`enable-dir-local-variables' are nil." (when (and enable-local-variables + enable-dir-local-variables (or enable-remote-dir-locals (not (file-remote-p (or (buffer-file-name) default-directory))))) diff --git a/lisp/tutorial.el b/lisp/tutorial.el index 011461119fc..39eb9e8b9aa 100644 --- a/lisp/tutorial.el +++ b/lisp/tutorial.el @@ -829,10 +829,9 @@ Run the Viper tutorial? ")) (progn (insert-file-contents (tutorial--saved-file)) (let ((enable-local-variables :safe) - (enable-local-eval nil)) + (enable-local-eval nil) + (enable-dir-local-variables nil)) ; bug#11127 (hack-local-variables)) - ;; FIXME? What we actually want is to ignore dir-locals (?). - (setq buffer-read-only nil) ; bug#11118 (goto-char (point-min)) (setq old-tut-point (string-to-number @@ -849,10 +848,9 @@ Run the Viper tutorial? ")) (setq tutorial--point-before-chkeys (point-marker))) (insert-file-contents (expand-file-name filename tutorial-directory)) (let ((enable-local-variables :safe) - (enable-local-eval nil)) + (enable-local-eval nil) + (enable-dir-local-variables nil)) ; bug#11127 (hack-local-variables)) - ;; FIXME? What we actually want is to ignore dir-locals (?). - (setq buffer-read-only nil) ; bug#11118 (forward-line) (setq tutorial--point-before-chkeys (point-marker)))