aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris <[email protected]>2013-02-10 17:50:45 -0800
committerGlenn Morris <[email protected]>2013-02-10 17:50:45 -0800
commit97a1cd9d27e7d95263b475d03ce39c20a2ff4512 (patch)
tree6ccbcec387797f9e1407c19169d7d4747a741784
parentc57b2d76277b678431d2926a542003e1275927a9 (diff)
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
-rw-r--r--etc/NEWS8
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/files.el11
-rw-r--r--lisp/tutorial.el10
4 files changed, 25 insertions, 9 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 2d1f456612..4525d70518 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 5b80c1dbdb..979c0808b7 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,10 @@
2013-02-11 Glenn Morris <[email protected]>
+ * 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 c9e5d2763f..890834d4af 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 011461119f..39eb9e8b9a 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)))