Mercurial > emacs
comparison lispref/variables.texi @ 68893:06f938e505d7
(File Local Variables): Clarifications.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 14 Feb 2006 20:58:28 +0000 |
parents | 17c1f4fa776d |
children | 485885718688 |
comparison
equal
deleted
inserted
replaced
68892:93b583aac002 | 68893:06f938e505d7 |
---|---|
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. Emacs takes several | 1776 visiting a file could take over your Emacs. Emacs takes several |
1777 measures to prevent this. | 1777 measures to prevent this. |
1778 | 1778 |
1779 @cindex safe local variable | 1779 @cindex safe local variable |
1780 When Emacs encounters a file local variable whose safety is not | 1780 A variable can be marked as @dfn{safe} by setting its |
1781 guaranteed, it asks the user whether or not to obey the file variable | 1781 @code{safe-local-variable} property. If the property is @code{t}, |
1782 specifications. If the user says no, Emacs ignores @emph{all} the | 1782 setting that variable in a file is always considered safe, regardless |
1783 file variables specified in that file. A variable can be marked as | 1783 of the value assigned to it. The @code{safe-local-variable} property |
1784 @dfn{safe} by setting its @code{safe-local-variable} property. If the | 1784 can also be a function of one argument. In that case, Emacs considers |
1785 property is @code{t}, that variable is always considered safe, | 1785 it safe to give the variable a certain value if the function returns |
1786 regardless of the value assigned to it. The | 1786 non-@code{nil} when given that value as argument. Many |
1787 @code{safe-local-variable} property can also be a function taking | 1787 commonly-encountered file variables standardly have |
1788 exactly one argument. In that case, Emacs considers it safe to give | 1788 @code{safe-local-variable} properties, including @code{fill-column}, |
1789 the variable a certain value if the function returns non-@code{nil} | 1789 @code{fill-prefix}, and @code{indent-tabs-mode}. |
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 | 1790 |
1795 @defopt safe-local-variable-values | 1791 @defopt safe-local-variable-values |
1796 This variable provides another way to mark variables as safe. It is a | 1792 This variable provides another way to mark some variable values as |
1797 list of cons cells @code{(var . val)}, where @var{var} is a variable | 1793 safe. It is a list of cons cells @code{(@var{var} . @var{val})}, |
1798 name and @var{val} is a value of that variable that is safe. | 1794 where @var{var} is a variable name and @var{val} is a value which is |
1795 safe for that variable. | |
1799 | 1796 |
1800 When Emacs asks the user whether or not to obey a set of file variable | 1797 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 | 1798 specifications, the user can choose to mark them as safe. Doing so |
1802 those variable-value pairs to @code{safe-local-variable-values}, and | 1799 adds those variable-value pairs to @code{safe-local-variable-values}, |
1803 saves it to the user's custom file. | 1800 and saves it to the user's custom file. |
1804 @end defopt | 1801 @end defopt |
1805 | 1802 |
1806 @defun safe-local-variable-p sym val | 1803 @defun safe-local-variable-p sym val |
1807 This function returns non-@code{nil} if it is safe to give @var{sym} | 1804 This function returns non-@code{nil} if it is safe to give @var{sym} |
1808 the value @var{val}, based on the above criteria. | 1805 the value @var{val}, based on the above criteria. |
1809 @end defun | 1806 @end defun |
1810 | 1807 |
1811 @cindex risky local variable | 1808 @cindex risky local variable |
1812 Some variables are considered @dfn{risky}. A variable whose name ends | 1809 Some variables are considered @dfn{risky}. A variable whose name |
1813 in any of @samp{-command}, @samp{-frame-alist}, @samp{-function}, | 1810 ends in any of @samp{-command}, @samp{-frame-alist}, @samp{-function}, |
1814 @samp{-functions}, @samp{-hook}, @samp{-hooks}, @samp{-form}, | 1811 @samp{-functions}, @samp{-hook}, @samp{-hooks}, @samp{-form}, |
1815 @samp{-forms}, @samp{-map}, @samp{-map-alist}, @samp{-mode-alist}, | 1812 @samp{-forms}, @samp{-map}, @samp{-map-alist}, @samp{-mode-alist}, |
1816 @samp{-program}, or @samp{-predicate} is considered risky. The | 1813 @samp{-program}, or @samp{-predicate} is considered risky. The |
1817 variables @samp{font-lock-keywords}, @samp{font-lock-keywords} | 1814 variables @samp{font-lock-keywords}, @samp{font-lock-keywords} |
1818 followed by a digit, and @samp{font-lock-syntactic-keywords} are also | 1815 followed by a digit, and @samp{font-lock-syntactic-keywords} are also |
1823 @defun risky-local-variable-p sym | 1820 @defun risky-local-variable-p sym |
1824 This function returns non-@code{nil} if @var{sym} is a risky variable, | 1821 This function returns non-@code{nil} if @var{sym} is a risky variable, |
1825 based on the above criteria. | 1822 based on the above criteria. |
1826 @end defun | 1823 @end defun |
1827 | 1824 |
1828 If a variable is risky, it will not be entered automatically into | 1825 If a variable is risky, it will not be entered automatically into |
1829 @code{safe-local-variable-values} as described above. Therefore, | 1826 @code{safe-local-variable-values} as described above. Therefore, |
1830 Emacs will always query before setting a risky variable, unless the | 1827 Emacs will always query before setting a risky variable, unless the |
1831 user explicitly allows it by editing @code{safe-local-variable-values} | 1828 user explicitly allows it by editing @code{safe-local-variable-values} |
1832 via Customize. | 1829 via Customize. |
1833 | 1830 |