aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2006-02-14 01:22:05 +0000
committerChong Yidong2006-02-14 01:22:05 +0000
commit51a39bab2e2c7de59181e6d6db171a5a45f435d3 (patch)
tree013bf98b4e8b48317a35222ffab38032eb3e9a17
parentf925e502c9293432abeac82167d5625aa781647b (diff)
downloademacs-51a39bab2e2c7de59181e6d6db171a5a45f435d3.tar.gz
emacs-51a39bab2e2c7de59181e6d6db171a5a45f435d3.zip
* variables.texi (File Local Variables): Document new file local
variable behavior.
-rw-r--r--lispref/ChangeLog5
-rw-r--r--lispref/variables.texi92
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 @@
12006-02-13 Chong Yidong <cyd@stupidchicken.com>
2
3 * variables.texi (File Local Variables): Document new file local
4 variable behavior.
5
12006-02-10 Kim F. Storm <storm@cua.dk> 62006-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
1754This variable controls whether to process file local variables. A 1754This variable controls whether to process file local variables. A
1755value of @code{t} means process them unconditionally; @code{nil} means 1755value of @code{t} means to process them, querying the user if unsafe
1756ignore them; anything else means ask the user what to do for each 1756variables are encountered; @code{nil} means ignore them; anything else
1757file. The default value is @code{t}. 1757means 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
1775be called later, or an expression that would be executed later, simply 1775be called later, or an expression that would be executed later, simply
1776visiting a file could take over your Emacs. To prevent this, Emacs 1776visiting a file could take over your Emacs. Emacs takes several
1777takes care not to allow to set such file local variables. 1777measures to prevent this.
1778
1779@cindex safe local variable
1780 When Emacs encounters a file local variable whose safety is not
1781guaranteed, it asks the user whether or not to obey the file variable
1782specifications. If the user says no, Emacs ignores @emph{all} the
1783file variables specified in that file. A variable can be marked as
1784@dfn{safe} by setting its @code{safe-local-variable} property. If the
1785property is @code{t}, that variable is always considered safe,
1786regardless of the value assigned to it. The
1787@code{safe-local-variable} property can also be a a function taking
1788exactly one argument. In that case, Emacs considers it safe to give
1789the variable a certain value if the function returns non-@code{nil}
1790when called with that value as argument. Many commonly-encountered
1791file variables possess @code{safe-local-variable} by default,
1792including @code{fill-column}, @code{fill-prefix}, and
1793@code{indent-tabs-mode}.
1794
1795@defopt safe-local-variable-values
1796This variable provides another way to mark variables as safe. It is a
1797list of cons cells @var{(var . val)}, where @var{var} is a variable
1798name and @var{val} is a value of that variable that is safe.
1799
1800When Emacs asks the user whether or not to obey a set of file variable
1801specifications, the user can choose to mark them as safe. This adds
1802those variable-value pairs to @code{safe-local-variable-values}, and
1803saves it to the user's custom file.
1804@end defopt
1805
1806@defun safe-local-variable-p sym val
1807This function returns non-@code{nil} if it is safe to give @var{sym}
1808the 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}, 1812Some variables are considered @dfn{risky}. A variable whose name ends
1813in 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
1784value. In general, you should use such a name whenever it is 1817variables @samp{font-lock-keywords}, @samp{font-lock-keywords}
1785appropriate for the variable's meaning. The variables 1818followed by a digit, and @samp{font-lock-syntactic-keywords} are also
1786@samp{font-lock-keywords}, @samp{font-lock-keywords} followed by a 1819considered risky. Finally, any variable whose name has a
1787digit, and @samp{font-lock-syntactic-keywords} cannot be given file 1820non-@code{nil} @code{risky-local-variable} property is considered
1788local values either. These rules can be overridden by giving the 1821risky.
1789variable's name a non-@code{nil} @code{safe-local-variable} property. 1822
1790If one gives it a @code{safe-local-variable} property of @code{t}, 1823@defun risky-local-variable-p sym
1791then one can give the variable any file local value. One can also 1824This function returns non-@code{nil} if @var{sym} is a risky variable,
1792give any symbol, including the above, a @code{safe-local-variable} 1825based on the above criteria.
1793property that is a function taking exactly one argument. In that 1826@end defun
1794case, giving a variable with that name a file local value is only 1827
1795allowed if the function returns non-@code{nil} when called with that 1828If a variable is risky, it will not be entered automatically into
1796value as argument. 1829@code{safe-local-variable-values} as described above. Therefore,
1797 1830Emacs will always query before setting a risky variable, unless the
1798 In addition, any variable whose name has a non-@code{nil} 1831user explicitly allows it by editing @code{safe-local-variable-values}
1799@code{risky-local-variable} property is also ignored. So are all 1832via Customize.
1800variables listed in @code{ignored-local-variables}:
1801 1833
1802@defvar ignored-local-variables 1834@defvar ignored-local-variables
1803This variable holds a list of variables that should not be given local 1835This variable holds a list of variables that should not be given local
1804values by files. Any value specified for one of these variables is 1836values by files. Any value specified for one of these variables is
1805ignored. 1837completely ignored.
1806@end defvar 1838@end defvar
1807 1839
1808@defun risky-local-variable-p sym &optional val
1809If @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
1811the reasons stated above. If @var{val} is @code{nil} or omitted, only
1812returns @code{nil} if @var{sym} can be safely assigned any file local
1813value 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
1817normally asks for confirmation before handling it. 1841normally asks for confirmation before handling it.
1818 1842