changeset 69936:19030d5ea7fe

(enable-local-variables): Allow value :safe. (normal-mode): Doc fix. (hack-local-variables): Implement enable-local-variables = :safe. (hack-local-variables-confirm): Don't prevent quitting.
author Richard M. Stallman <rms@gnu.org>
date Tue, 11 Apr 2006 17:57:34 +0000
parents 3fc0524ae318
children b47563345c03
files lisp/files.el
diffstat 1 files changed, 27 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/files.el	Tue Apr 11 17:05:16 2006 +0000
+++ b/lisp/files.el	Tue Apr 11 17:57:34 2006 +0000
@@ -444,14 +444,19 @@
 
 (defcustom enable-local-variables t
   "*Control use of local variables in files you visit.
-The value can be t, nil or something else.
+The value can be t, nil, :safe, or something else.
 
 A value of t means file local variables specifications are obeyed
 if all the specified variable values are safe; if any values are
 not safe, Emacs queries you, once, whether to set them all.
-
-A value of nil means always ignore the file local variables.
+\(When you say yes to certain values, they are remembered as safe.)
+
+:safe means set the safe variables, and ignore the rest.
+nil means always ignore the file local variables.
+
 Any other value means always query you once whether to set them all.
+\(When you say yes to certain values, they are remembered as safe, but
+this has no effect when `enable-local-variables' is \"something else\".)
 
 This variable also controls use of major modes specified in
 a -*- line.
@@ -460,6 +465,7 @@
 always obeys file local variable specifications and the -*- line,
 and ignores this variable."
   :type '(choice (const :tag "Obey" t)
+		 (const :tag "Safe Only" :safe)
 		 (const :tag "Ignore" nil)
 		 (other :tag "Query" other))
   :group 'find-file)
@@ -1779,8 +1785,7 @@
 
 This function is called automatically from `find-file'.  In that case,
 we may set up the file-specified mode and local variables,
-depending on the value of `enable-local-variables': if it is t, we do;
-if it is nil, we don't; otherwise, we query.
+depending on the value of `enable-local-variables'.
 In addition, if `local-enable-local-variables' is nil, we do
 not set local variables (though we do notice a mode specified with -*-.)
 
@@ -2413,8 +2418,7 @@
 			    ""
 			  ", or C-v to scroll")))
 	  (goto-char (point-min))
-	  (let ((inhibit-quit t)
-		(cursor-in-echo-area t)
+	  (let ((cursor-in-echo-area t)
 		(exit-chars
 		 (if offer-save '(?! ?y ?n ?\s ?\C-g) '(?y ?n ?\s ?\C-g)))
 		done)
@@ -2426,9 +2430,7 @@
 		      (condition-case nil
 			  (scroll-up)
 			(error (goto-char (point-min))))
-		    (setq done (memq (downcase char) exit-chars)))))
-	    (if (= char ?\C-g)
-		(setq quit-flag nil)))
+		    (setq done (memq (downcase char) exit-chars))))))
 	  (setq char (downcase char))
 	  (when (and offer-save (= char ?!) unsafe-vars)
 	    (dolist (elt unsafe-vars)
@@ -2616,13 +2618,22 @@
 		    (and (risky-local-variable-p var val)
 			 (push elt risky-vars))
 		    (push elt unsafe-vars))))
-	    (if (or (and (eq enable-local-variables t)
-			 (null unsafe-vars)
-			 (null risky-vars))
-		    (hack-local-variables-confirm
-		     result unsafe-vars risky-vars))
+	    (if (eq enable-local-variables :safe)
+		;; If caller wants only the safe variables,
+		;; install only them.
 		(dolist (elt result)
-		  (hack-one-local-variable (car elt) (cdr elt)))))
+		  (unless (or (memq (car elt) unsafe-vars)
+			      (memq (car elt) risky-vars))
+		    (hack-one-local-variable (car elt) (cdr elt))))
+	      ;; Query, except in the case where all are known safe
+	      ;; if the user wants no quuery in that case.
+	      (if (or (and (eq enable-local-variables t)
+			   (null unsafe-vars)
+			   (null risky-vars))
+		      (hack-local-variables-confirm
+		       result unsafe-vars risky-vars))
+		  (dolist (elt result)
+		    (hack-one-local-variable (car elt) (cdr elt))))))
 	  (run-hooks 'hack-local-variables-hook))))))
 
 (defun safe-local-variable-p (sym val)