diff options
| author | Chong Yidong | 2006-02-14 01:22:05 +0000 |
|---|---|---|
| committer | Chong Yidong | 2006-02-14 01:22:05 +0000 |
| commit | 51a39bab2e2c7de59181e6d6db171a5a45f435d3 (patch) | |
| tree | 013bf98b4e8b48317a35222ffab38032eb3e9a17 | |
| parent | f925e502c9293432abeac82167d5625aa781647b (diff) | |
| download | emacs-51a39bab2e2c7de59181e6d6db171a5a45f435d3.tar.gz emacs-51a39bab2e2c7de59181e6d6db171a5a45f435d3.zip | |
* variables.texi (File Local Variables): Document new file local
variable behavior.
| -rw-r--r-- | lispref/ChangeLog | 5 | ||||
| -rw-r--r-- | lispref/variables.texi | 92 |
2 files changed, 63 insertions, 34 deletions
diff --git a/lispref/ChangeLog b/lispref/ChangeLog index b396e8b3ee7..250d5450608 100644 --- a/lispref/ChangeLog +++ b/lispref/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2006-02-13 Chong Yidong <cyd@stupidchicken.com> | ||
| 2 | |||
| 3 | * variables.texi (File Local Variables): Document new file local | ||
| 4 | variable behavior. | ||
| 5 | |||
| 1 | 2006-02-10 Kim F. Storm <storm@cua.dk> | 6 | 2006-02-10 Kim F. Storm <storm@cua.dk> |
| 2 | 7 | ||
| 3 | * eval.texi (Function Indirection): Add NOERROR to indirect-function. | 8 | * eval.texi (Function Indirection): Add NOERROR to indirect-function. |
diff --git a/lispref/variables.texi b/lispref/variables.texi index 32a6e9b7873..8b54d02758e 100644 --- a/lispref/variables.texi +++ b/lispref/variables.texi | |||
| @@ -1752,9 +1752,9 @@ information about file local variables. | |||
| 1752 | 1752 | ||
| 1753 | @defopt enable-local-variables | 1753 | @defopt enable-local-variables |
| 1754 | This variable controls whether to process file local variables. A | 1754 | This variable controls whether to process file local variables. A |
| 1755 | value of @code{t} means process them unconditionally; @code{nil} means | 1755 | value of @code{t} means to process them, querying the user if unsafe |
| 1756 | ignore them; anything else means ask the user what to do for each | 1756 | variables are encountered; @code{nil} means ignore them; anything else |
| 1757 | file. The default value is @code{t}. | 1757 | means to query the user for each file. The default value is @code{t}. |
| 1758 | @end defopt | 1758 | @end defopt |
| 1759 | 1759 | ||
| 1760 | @defun hack-local-variables &optional mode-only | 1760 | @defun hack-local-variables &optional mode-only |
| @@ -1773,46 +1773,70 @@ It does not set the mode nor any other file local variable. | |||
| 1773 | 1773 | ||
| 1774 | If a file local variable could specify a function that would | 1774 | If a file local variable could specify a function that would |
| 1775 | be called later, or an expression that would be executed later, simply | 1775 | be called later, or an expression that would be executed later, simply |
| 1776 | visiting a file could take over your Emacs. To prevent this, Emacs | 1776 | visiting a file could take over your Emacs. Emacs takes several |
| 1777 | takes care not to allow to set such file local variables. | 1777 | measures to prevent this. |
| 1778 | |||
| 1779 | @cindex safe local variable | ||
| 1780 | When Emacs encounters a file local variable whose safety is not | ||
| 1781 | guaranteed, it asks the user whether or not to obey the file variable | ||
| 1782 | specifications. If the user says no, Emacs ignores @emph{all} the | ||
| 1783 | file variables specified in that file. A variable can be marked as | ||
| 1784 | @dfn{safe} by setting its @code{safe-local-variable} property. If the | ||
| 1785 | property is @code{t}, that variable is always considered safe, | ||
| 1786 | regardless of the value assigned to it. The | ||
| 1787 | @code{safe-local-variable} property can also be a a function taking | ||
| 1788 | exactly one argument. In that case, Emacs considers it safe to give | ||
| 1789 | the variable a certain value if the function returns non-@code{nil} | ||
| 1790 | when called with that value as argument. Many commonly-encountered | ||
| 1791 | file variables possess @code{safe-local-variable} by default, | ||
| 1792 | including @code{fill-column}, @code{fill-prefix}, and | ||
| 1793 | @code{indent-tabs-mode}. | ||
| 1794 | |||
| 1795 | @defopt safe-local-variable-values | ||
| 1796 | This variable provides another way to mark variables as safe. It is a | ||
| 1797 | list of cons cells @var{(var . val)}, where @var{var} is a variable | ||
| 1798 | name and @var{val} is a value of that variable that is safe. | ||
| 1799 | |||
| 1800 | When Emacs asks the user whether or not to obey a set of file variable | ||
| 1801 | specifications, the user can choose to mark them as safe. This adds | ||
| 1802 | those variable-value pairs to @code{safe-local-variable-values}, and | ||
| 1803 | saves it to the user's custom file. | ||
| 1804 | @end defopt | ||
| 1805 | |||
| 1806 | @defun safe-local-variable-p sym val | ||
| 1807 | This function returns non-@code{nil} if it is safe to give @var{sym} | ||
| 1808 | the value @var{val}, based on the above criteria. | ||
| 1809 | @end defun | ||
| 1778 | 1810 | ||
| 1779 | For one thing, any variable whose name ends in any of | 1811 | @cindex risky local variable |
| 1780 | @samp{-command}, @samp{-frame-alist}, @samp{-function}, | 1812 | Some variables are considered @dfn{risky}. A variable whose name ends |
| 1813 | in any of @samp{-command}, @samp{-frame-alist}, @samp{-function}, | ||
| 1781 | @samp{-functions}, @samp{-hook}, @samp{-hooks}, @samp{-form}, | 1814 | @samp{-functions}, @samp{-hook}, @samp{-hooks}, @samp{-form}, |
| 1782 | @samp{-forms}, @samp{-map}, @samp{-map-alist}, @samp{-mode-alist}, | 1815 | @samp{-forms}, @samp{-map}, @samp{-map-alist}, @samp{-mode-alist}, |
| 1783 | @samp{-program}, or @samp{-predicate} cannot be given a file local | 1816 | @samp{-program}, or @samp{-predicate} is considered risky. The |
| 1784 | value. In general, you should use such a name whenever it is | 1817 | variables @samp{font-lock-keywords}, @samp{font-lock-keywords} |
| 1785 | appropriate for the variable's meaning. The variables | 1818 | followed by a digit, and @samp{font-lock-syntactic-keywords} are also |
| 1786 | @samp{font-lock-keywords}, @samp{font-lock-keywords} followed by a | 1819 | considered risky. Finally, any variable whose name has a |
| 1787 | digit, and @samp{font-lock-syntactic-keywords} cannot be given file | 1820 | non-@code{nil} @code{risky-local-variable} property is considered |
| 1788 | local values either. These rules can be overridden by giving the | 1821 | risky. |
| 1789 | variable's name a non-@code{nil} @code{safe-local-variable} property. | 1822 | |
| 1790 | If one gives it a @code{safe-local-variable} property of @code{t}, | 1823 | @defun risky-local-variable-p sym |
| 1791 | then one can give the variable any file local value. One can also | 1824 | This function returns non-@code{nil} if @var{sym} is a risky variable, |
| 1792 | give any symbol, including the above, a @code{safe-local-variable} | 1825 | based on the above criteria. |
| 1793 | property that is a function taking exactly one argument. In that | 1826 | @end defun |
| 1794 | case, giving a variable with that name a file local value is only | 1827 | |
| 1795 | allowed if the function returns non-@code{nil} when called with that | 1828 | If a variable is risky, it will not be entered automatically into |
| 1796 | value as argument. | 1829 | @code{safe-local-variable-values} as described above. Therefore, |
| 1797 | 1830 | Emacs will always query before setting a risky variable, unless the | |
| 1798 | In addition, any variable whose name has a non-@code{nil} | 1831 | user explicitly allows it by editing @code{safe-local-variable-values} |
| 1799 | @code{risky-local-variable} property is also ignored. So are all | 1832 | via Customize. |
| 1800 | variables listed in @code{ignored-local-variables}: | ||
| 1801 | 1833 | ||
| 1802 | @defvar ignored-local-variables | 1834 | @defvar ignored-local-variables |
| 1803 | This variable holds a list of variables that should not be given local | 1835 | This variable holds a list of variables that should not be given local |
| 1804 | values by files. Any value specified for one of these variables is | 1836 | values by files. Any value specified for one of these variables is |
| 1805 | ignored. | 1837 | completely ignored. |
| 1806 | @end defvar | 1838 | @end defvar |
| 1807 | 1839 | ||
| 1808 | @defun risky-local-variable-p sym &optional val | ||
| 1809 | If @var{val} is non-@code{nil}, returns non-@code{nil} if giving | ||
| 1810 | @var{sym} a file local value of @var{val} would be risky, for any of | ||
| 1811 | the reasons stated above. If @var{val} is @code{nil} or omitted, only | ||
| 1812 | returns @code{nil} if @var{sym} can be safely assigned any file local | ||
| 1813 | value whatsoever. | ||
| 1814 | @end defun | ||
| 1815 | |||
| 1816 | The @samp{Eval:} ``variable'' is also a potential loophole, so Emacs | 1840 | The @samp{Eval:} ``variable'' is also a potential loophole, so Emacs |
| 1817 | normally asks for confirmation before handling it. | 1841 | normally asks for confirmation before handling it. |
| 1818 | 1842 | ||