diff options
| author | Richard M. Stallman | 2006-04-11 17:57:34 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2006-04-11 17:57:34 +0000 |
| commit | a5ce12c36abccb735ed79bef208c8a0936a618ca (patch) | |
| tree | 85253607e8bf41a1637ea2e4c758d091eda5402d | |
| parent | ab215e7246b0fd5fab2322a708340d6f2c9e455d (diff) | |
| download | emacs-a5ce12c36abccb735ed79bef208c8a0936a618ca.tar.gz emacs-a5ce12c36abccb735ed79bef208c8a0936a618ca.zip | |
(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.
| -rw-r--r-- | lisp/files.el | 41 |
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. |
| 447 | The value can be t, nil or something else. | 447 | The value can be t, nil, :safe, or something else. |
| 448 | 448 | ||
| 449 | A value of t means file local variables specifications are obeyed | 449 | A value of t means file local variables specifications are obeyed |
| 450 | if all the specified variable values are safe; if any values are | 450 | if all the specified variable values are safe; if any values are |
| 451 | not safe, Emacs queries you, once, whether to set them all. | 451 | not 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. | ||
| 455 | nil means always ignore the file local variables. | ||
| 452 | 456 | ||
| 453 | A value of nil means always ignore the file local variables. | ||
| 454 | Any other value means always query you once whether to set them all. | 457 | Any 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 | ||
| 459 | this has no effect when `enable-local-variables' is \"something else\".) | ||
| 455 | 460 | ||
| 456 | This variable also controls use of major modes specified in | 461 | This variable also controls use of major modes specified in |
| 457 | a -*- line. | 462 | a -*- line. |
| @@ -460,6 +465,7 @@ The command \\[normal-mode], when used interactively, | |||
| 460 | always obeys file local variable specifications and the -*- line, | 465 | always obeys file local variable specifications and the -*- line, |
| 461 | and ignores this variable." | 466 | and 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 | ||
| 1780 | This function is called automatically from `find-file'. In that case, | 1786 | This function is called automatically from `find-file'. In that case, |
| 1781 | we may set up the file-specified mode and local variables, | 1787 | we may set up the file-specified mode and local variables, |
| 1782 | depending on the value of `enable-local-variables': if it is t, we do; | 1788 | depending on the value of `enable-local-variables'. |
| 1783 | if it is nil, we don't; otherwise, we query. | ||
| 1784 | In addition, if `local-enable-local-variables' is nil, we do | 1789 | In addition, if `local-enable-local-variables' is nil, we do |
| 1785 | not set local variables (though we do notice a mode specified with -*-.) | 1790 | not 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) |