1784 |
@section File Local Variables |
@section File Local Variables |
1785 |
|
|
1786 |
This section describes the functions and variables that affect |
This section describes the functions and variables that affect |
1787 |
processing of local variables lists in files. @xref{File variables, , |
processing of file local variables. @xref{File variables, , |
1788 |
Local Variables in Files, emacs, The GNU Emacs Manual}, for basic |
Local Variables in Files, emacs, The GNU Emacs Manual}, for basic |
1789 |
information about file local variables. |
information about file local variables. |
1790 |
|
|
1791 |
@defopt enable-local-variables |
@defopt enable-local-variables |
1792 |
This variable controls whether to process file local variables lists. A |
This variable controls whether to process file local variables. A |
1793 |
value of @code{t} means process the local variables lists |
value of @code{t} means process them unconditionally; @code{nil} means |
1794 |
unconditionally; @code{nil} means ignore them; anything else means ask |
ignore them; anything else means ask the user what to do for each |
1795 |
the user what to do for each file. The default value is @code{t}. |
file. The default value is @code{t}. |
1796 |
@end defopt |
@end defopt |
1797 |
|
|
1798 |
@defun hack-local-variables &optional mode-only |
@defun hack-local-variables &optional mode-only |
1801 |
@code{enable-local-variables} has its effect here. However, this |
@code{enable-local-variables} has its effect here. However, this |
1802 |
function does not look for the @samp{mode:} local variable in the |
function does not look for the @samp{mode:} local variable in the |
1803 |
@w{@samp{-*-}} line. @code{set-auto-mode} does that, also taking |
@w{@samp{-*-}} line. @code{set-auto-mode} does that, also taking |
1804 |
@code{enable-local-variables} into account. |
@code{enable-local-variables} into account (@pxref{Auto Major Mode}). |
1805 |
|
|
1806 |
If the optional argument @var{mode-only} is non-@code{nil}, then all |
If the optional argument @var{mode-only} is non-@code{nil}, then all |
1807 |
this function does is return @code{t} if the @w{@samp{-*-}} line or |
this function does is return @code{t} if the @w{@samp{-*-}} line or |
1809 |
It does not set the mode nor any other file local variable. |
It does not set the mode nor any other file local variable. |
1810 |
@end defun |
@end defun |
1811 |
|
|
1812 |
If a file local variable list could specify a function that would |
If a file local variable could specify a function that would |
1813 |
be called later, or an expression that would be executed later, simply |
be called later, or an expression that would be executed later, simply |
1814 |
visiting a file could take over your Emacs. To prevent this, Emacs |
visiting a file could take over your Emacs. To prevent this, Emacs |
1815 |
takes care not to allow local variable lists to set such variables. |
takes care not to allow to set such file local variables. |
1816 |
|
|
1817 |
For one thing, any variable whose name ends in @samp{-command}, |
For one thing, any variable whose name ends in @samp{-command}, |
1818 |
@samp{-frame-alist}, @samp{-function}, @samp{-functions}, |
@samp{-frame-alist}, @samp{-function}, @samp{-functions}, |
1819 |
@samp{-hook}, @samp{-hooks}, @samp{-form}, @samp{-forms}, @samp{-map}, |
@samp{-hook}, @samp{-hooks}, @samp{-form}, @samp{-forms}, @samp{-map}, |
1820 |
@samp{-map-alist}, @samp{-mode-alist}, @samp{-program}, or |
@samp{-map-alist}, @samp{-mode-alist}, @samp{-program}, or |
1821 |
@samp{-predicate} cannot be set in a local variable list. In general, |
@samp{-predicate} cannot be given a file local value. In general, |
1822 |
you should use such a name whenever it is appropriate for the |
you should use such a name whenever it is appropriate for the |
1823 |
variable's meaning. The variables @samp{font-lock-keywords}, |
variable's meaning. The variables @samp{font-lock-keywords}, |
1824 |
@samp{font-lock-keywords-[0-9]}, and |
@samp{font-lock-keywords-[0-9]}, and |
1825 |
@samp{font-lock-syntactic-keywords} cannot be set in a local variable |
@samp{font-lock-syntactic-keywords} cannot be given file local values either. |
1826 |
list, either. These rules can be overridden by giving the variable's |
These rules can be overridden by giving the variable's |
1827 |
name a non-@code{nil} @code{safe-local-variable} property. If one |
name a non-@code{nil} @code{safe-local-variable} property. If one |
1828 |
gives it a @code{safe-local-variable} property of @code{t}, then one |
gives it a @code{safe-local-variable} property of @code{t}, then one |
1829 |
can give the variable any file local value. One can also give any |
can give the variable any file local value. One can also give any |
1838 |
variables listed in @code{ignored-local-variables}: |
variables listed in @code{ignored-local-variables}: |
1839 |
|
|
1840 |
@defvar ignored-local-variables |
@defvar ignored-local-variables |
1841 |
This variable holds a list of variables that should not be |
This variable holds a list of variables that should not be given local |
1842 |
set by a file's local variables list. Any value specified |
values by files. Any value specified for one of these variables is |
1843 |
for one of these variables is ignored. |
ignored. |
1844 |
@end defvar |
@end defvar |
1845 |
|
|
1846 |
@defun risky-local-variable-p sym &optional val |
@defun risky-local-variable-p sym &optional val |
1855 |
normally asks for confirmation before handling it. |
normally asks for confirmation before handling it. |
1856 |
|
|
1857 |
@defopt enable-local-eval |
@defopt enable-local-eval |
1858 |
This variable controls processing of @samp{Eval:} in local variables |
This variable controls processing of @samp{Eval:} in @samp{-*-} lines |
1859 |
|
or local variables |
1860 |
lists in files being visited. A value of @code{t} means process them |
lists in files being visited. A value of @code{t} means process them |
1861 |
unconditionally; @code{nil} means ignore them; anything else means ask |
unconditionally; @code{nil} means ignore them; anything else means ask |
1862 |
the user what to do for each file. The default value is @code{maybe}. |
the user what to do for each file. The default value is @code{maybe}. |
1864 |
|
|
1865 |
Text properties are also potential loopholes, since their values |
Text properties are also potential loopholes, since their values |
1866 |
could include functions to call. So Emacs discards all text |
could include functions to call. So Emacs discards all text |
1867 |
properties from string values specified in a file's local variables |
properties from string values specified for file local variables. |
|
list. |
|
1868 |
|
|
1869 |
@node Variables with Restricted Values |
@node Variables with Restricted Values |
1870 |
@section Variables with Restricted Values |
@section Variables with Restricted Values |