[ < ] [ > ]   [ << ] [Plus haut] [ >> ]         [Top] [Table des matières] [Index] [ ? ]

57.3.4.2 Safety of File Variables

File-local variables can be dangerous; when you visit someone else's file, there's no telling what its local variables list could do to your Emacs. Improper values of the eval “variable,” and other variables such as load-path, could execute Lisp code you didn't intend to run.

Therefore, whenever Emacs encounters file local variable values that are not known to be safe, it displays the file's entire local variables list, and asks you for confirmation before setting them. You can type y or <SPC> to put the local variables list into effect, or n to ignore it. When Emacs is run in batch mode (voir la section Initial Options), it can't really ask you, so it assumes the answer n.

Emacs normally recognizes certain variables/value pairs as safe. For instance, it is safe to give comment-column or fill-column any integer value. If a file specifies only known-safe variable/value pairs, Emacs does not ask for confirmation before setting them. Otherwise, you can tell Emacs to record all the variable/value pairs in this file as safe, by typing ! at the confirmation prompt. When Emacs encounters these variable/value pairs subsequently, in the same file or others, it will assume they are safe.

Some variables, such as load-path, are considered particularly risky: there is seldom any reason to specify them as local variables, and changing them can be dangerous. Even if you enter ! at the confirmation prompt, Emacs will not record any values as safe for these variables. If you really want to record safe values for these variables, do it directly by customizing ‘safe-local-variable-values’ (voir la section Easy Customization Interface).

The variable enable-local-variables allows you to change the way Emacs processes local variables. Its default value is t, which specifies the behavior described above. If it is nil, Emacs simply ignores all file local variables. :safe means use only the safe values and ignore the rest. Any other value says to query you about each file that has local variables, without trying to determine whether the values are known to be safe.

The variable enable-local-eval controls whether Emacs processes eval variables. The three possibilities for the variable's value are t, nil, and anything else, just as for enable-local-variables. The default is maybe, which is neither t nor nil, so normally Emacs does ask for confirmation about processing eval variables.

But there is an exception. The safe-local-eval-forms is a customizable list of eval forms which are safe. Emacs does not ask for confirmation when it finds these forms for the eval variable.


[ < ] [ > ]   [ << ] [Plus haut] [ >> ]         [Top] [Table des matières] [Index] [ ? ]

Ce document a été généré par Eric Reinbold le 23 Février 2009 en utilisant texi2html 1.78.