aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/files.el41
1 files changed, 26 insertions, 15 deletions
diff --git a/lisp/files.el b/lisp/files.el
index 3e4602643db..ca03ee8726b 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -444,14 +444,19 @@ use `before-save-hook'.")
444 444
445(defcustom enable-local-variables t 445(defcustom enable-local-variables t
446 "*Control use of local variables in files you visit. 446 "*Control use of local variables in files you visit.
447The value can be t, nil or something else. 447The value can be t, nil, :safe, or something else.
448 448
449A value of t means file local variables specifications are obeyed 449A value of t means file local variables specifications are obeyed
450if all the specified variable values are safe; if any values are 450if all the specified variable values are safe; if any values are
451not safe, Emacs queries you, once, whether to set them all. 451not safe, Emacs queries you, once, whether to set them all.
452\(When you say yes to certain values, they are remembered as safe.)
453
454:safe means set the safe variables, and ignore the rest.
455nil means always ignore the file local variables.
452 456
453A value of nil means always ignore the file local variables.
454Any other value means always query you once whether to set them all. 457Any other value means always query you once whether to set them all.
458\(When you say yes to certain values, they are remembered as safe, but
459this has no effect when `enable-local-variables' is \"something else\".)
455 460
456This variable also controls use of major modes specified in 461This variable also controls use of major modes specified in
457a -*- line. 462a -*- line.
@@ -460,6 +465,7 @@ The command \\[normal-mode], when used interactively,
460always obeys file local variable specifications and the -*- line, 465always obeys file local variable specifications and the -*- line,
461and ignores this variable." 466and ignores this variable."
462 :type '(choice (const :tag "Obey" t) 467 :type '(choice (const :tag "Obey" t)
468 (const :tag "Safe Only" :safe)
463 (const :tag "Ignore" nil) 469 (const :tag "Ignore" nil)
464 (other :tag "Query" other)) 470 (other :tag "Query" other))
465 :group 'find-file) 471 :group 'find-file)
@@ -1779,8 +1785,7 @@ Uses the visited file name, the -*- line, and the local variables spec.
1779 1785
1780This function is called automatically from `find-file'. In that case, 1786This function is called automatically from `find-file'. In that case,
1781we may set up the file-specified mode and local variables, 1787we may set up the file-specified mode and local variables,
1782depending on the value of `enable-local-variables': if it is t, we do; 1788depending on the value of `enable-local-variables'.
1783if it is nil, we don't; otherwise, we query.
1784In addition, if `local-enable-local-variables' is nil, we do 1789In addition, if `local-enable-local-variables' is nil, we do
1785not set local variables (though we do notice a mode specified with -*-.) 1790not set local variables (though we do notice a mode specified with -*-.)
1786 1791
@@ -2413,8 +2418,7 @@ n -- to ignore the local variables list.")
2413 "" 2418 ""
2414 ", or C-v to scroll"))) 2419 ", or C-v to scroll")))
2415 (goto-char (point-min)) 2420 (goto-char (point-min))
2416 (let ((inhibit-quit t) 2421 (let ((cursor-in-echo-area t)
2417 (cursor-in-echo-area t)
2418 (exit-chars 2422 (exit-chars
2419 (if offer-save '(?! ?y ?n ?\s ?\C-g) '(?y ?n ?\s ?\C-g))) 2423 (if offer-save '(?! ?y ?n ?\s ?\C-g) '(?y ?n ?\s ?\C-g)))
2420 done) 2424 done)
@@ -2426,9 +2430,7 @@ n -- to ignore the local variables list.")
2426 (condition-case nil 2430 (condition-case nil
2427 (scroll-up) 2431 (scroll-up)
2428 (error (goto-char (point-min)))) 2432 (error (goto-char (point-min))))
2429 (setq done (memq (downcase char) exit-chars))))) 2433 (setq done (memq (downcase char) exit-chars))))))
2430 (if (= char ?\C-g)
2431 (setq quit-flag nil)))
2432 (setq char (downcase char)) 2434 (setq char (downcase char))
2433 (when (and offer-save (= char ?!) unsafe-vars) 2435 (when (and offer-save (= char ?!) unsafe-vars)
2434 (dolist (elt unsafe-vars) 2436 (dolist (elt unsafe-vars)
@@ -2616,13 +2618,22 @@ is specified, returning t if it is specified."
2616 (and (risky-local-variable-p var val) 2618 (and (risky-local-variable-p var val)
2617 (push elt risky-vars)) 2619 (push elt risky-vars))
2618 (push elt unsafe-vars)))) 2620 (push elt unsafe-vars))))
2619 (if (or (and (eq enable-local-variables t) 2621 (if (eq enable-local-variables :safe)
2620 (null unsafe-vars) 2622 ;; If caller wants only the safe variables,
2621 (null risky-vars)) 2623 ;; install only them.
2622 (hack-local-variables-confirm
2623 result unsafe-vars risky-vars))
2624 (dolist (elt result) 2624 (dolist (elt result)
2625 (hack-one-local-variable (car elt) (cdr elt))))) 2625 (unless (or (memq (car elt) unsafe-vars)
2626 (memq (car elt) risky-vars))
2627 (hack-one-local-variable (car elt) (cdr elt))))
2628 ;; Query, except in the case where all are known safe
2629 ;; if the user wants no quuery in that case.
2630 (if (or (and (eq enable-local-variables t)
2631 (null unsafe-vars)
2632 (null risky-vars))
2633 (hack-local-variables-confirm
2634 result unsafe-vars risky-vars))
2635 (dolist (elt result)
2636 (hack-one-local-variable (car elt) (cdr elt))))))
2626 (run-hooks 'hack-local-variables-hook)))))) 2637 (run-hooks 'hack-local-variables-hook))))))
2627 2638
2628(defun safe-local-variable-p (sym val) 2639(defun safe-local-variable-p (sym val)