aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuc Teirlinck2003-11-05 04:31:43 +0000
committerLuc Teirlinck2003-11-05 04:31:43 +0000
commitf36e17982d9de253a8819db80a3562e9a2a4938e (patch)
treebaaf971bc04f7aba610e1f4f45c50325b0fc29ea
parent40ebe9bdd7e71e180478e85583899b9a96456666 (diff)
downloademacs-f36e17982d9de253a8819db80a3562e9a2a4938e.tar.gz
emacs-f36e17982d9de253a8819db80a3562e9a2a4938e.zip
(Defining Variables): Second argument to `defconst' is not optional.
(Setting Variables): Mention optional argument APPEND to `add-to-list'. (Creating Buffer-Local): Expand description of `make-variable-buffer-local'. (Frame-Local Variables): Expand description of `make-variable-frame-local'. (Variable Aliases): Correct description of optional argument DOCSTRING to `defvaralias'. Mention return value of `defvaralias'. (File Local Variables): Add xref to `File variables' in Emacs Manual. Correct description of `hack-local-variables'. Mention `safe-local-variable' property. Mention optional second argument to `risky-local-variable-p'.
-rw-r--r--lispref/variables.texi79
1 files changed, 61 insertions, 18 deletions
diff --git a/lispref/variables.texi b/lispref/variables.texi
index d9431b7fd9e..36cc2e47fe4 100644
--- a/lispref/variables.texi
+++ b/lispref/variables.texi
@@ -518,7 +518,7 @@ The @code{defvar} form returns @var{symbol}, but it is normally used
518at top level in a file where its value does not matter. 518at top level in a file where its value does not matter.
519@end defspec 519@end defspec
520 520
521@defspec defconst symbol [value [doc-string]] 521@defspec defconst symbol value [doc-string]
522This special form defines @var{symbol} as a value and initializes it. 522This special form defines @var{symbol} as a value and initializes it.
523It informs a person reading your code that @var{symbol} has a standard 523It informs a person reading your code that @var{symbol} has a standard
524global value, established here, that should not be changed by the user 524global value, established here, that should not be changed by the user
@@ -526,10 +526,10 @@ or by other programs. Note that @var{symbol} is not evaluated; the
526symbol to be defined must appear explicitly in the @code{defconst}. 526symbol to be defined must appear explicitly in the @code{defconst}.
527 527
528@code{defconst} always evaluates @var{value}, and sets the value of 528@code{defconst} always evaluates @var{value}, and sets the value of
529@var{symbol} to the result if @var{value} is given. If @var{symbol} 529@var{symbol} to the result. If @var{symbol} does have a buffer-local
530does have a buffer-local binding in the current buffer, @code{defconst} 530binding in the current buffer, @code{defconst} sets the default value,
531sets the default value, not the buffer-local value. (But you should not 531not the buffer-local value. (But you should not be making
532be making buffer-local bindings for a symbol that is defined with 532buffer-local bindings for a symbol that is defined with
533@code{defconst}.) 533@code{defconst}.)
534 534
535Here, @code{pi} is a constant that presumably ought not to be changed 535Here, @code{pi} is a constant that presumably ought not to be changed
@@ -858,11 +858,16 @@ always affects the most local existing binding.
858 One other function for setting a variable is designed to add 858 One other function for setting a variable is designed to add
859an element to a list if it is not already present in the list. 859an element to a list if it is not already present in the list.
860 860
861@defun add-to-list symbol element 861@defun add-to-list symbol element &optional append
862This function sets the variable @var{symbol} by consing @var{element} 862This function sets the variable @var{symbol} by consing @var{element}
863onto the old value, if @var{element} is not already a member of that 863onto the old value, if @var{element} is not already a member of that
864value. It returns the resulting list, whether updated or not. The 864value. It returns the resulting list, whether updated or not. The
865value of @var{symbol} had better be a list already before the call. 865value of @var{symbol} had better be a list already before the call.
866Membership is tested using @code{equal}.
867
868Normally, if @var{element} is added, it is added to the front of
869@var{symbol}, but if the optional argument @var{append} is
870non-@code{nil}, it is added at the end.
866 871
867The argument @var{symbol} is not implicitly quoted; @code{add-to-list} 872The argument @var{symbol} is not implicitly quoted; @code{add-to-list}
868is an ordinary function, like @code{set} and unlike @code{setq}. Quote 873is an ordinary function, like @code{set} and unlike @code{setq}. Quote
@@ -1296,7 +1301,14 @@ local to the current buffer at the time.
1296A peculiar wrinkle of this feature is that binding the variable (with 1301A peculiar wrinkle of this feature is that binding the variable (with
1297@code{let} or other binding constructs) does not create a buffer-local 1302@code{let} or other binding constructs) does not create a buffer-local
1298binding for it. Only setting the variable (with @code{set} or 1303binding for it. Only setting the variable (with @code{set} or
1299@code{setq}) does so. 1304@code{setq}), while the variable does not have a @code{let}-style
1305binding that was made in the current buffer, does so.
1306
1307If @var{variable} does not have a default value, then calling this
1308command will give it a default value of @code{nil}. If @var{variable}
1309already has a default value, that value remains unchanged.
1310Subsequently calling @code{makunbound} on @var{variable} will result
1311in a void buffer-local value and leave the default value unaffected.
1300 1312
1301The value returned is @var{variable}. 1313The value returned is @var{variable}.
1302 1314
@@ -1556,11 +1568,17 @@ not in itself create any frame-local bindings for the variable; however,
1556if some frame already has a value for @var{variable} as a frame 1568if some frame already has a value for @var{variable} as a frame
1557parameter, that value automatically becomes a frame-local binding. 1569parameter, that value automatically becomes a frame-local binding.
1558 1570
1571If @var{variable} does not have a default value, then calling this
1572command will give it a default value of @code{nil}. If @var{variable}
1573already has a default value, that value remains unchanged.
1574
1559If the variable is terminal-local, this function signals an error, 1575If the variable is terminal-local, this function signals an error,
1560because such variables cannot have frame-local bindings as well. 1576because such variables cannot have frame-local bindings as well.
1561@xref{Multiple Displays}. A few variables that are implemented 1577@xref{Multiple Displays}. A few variables that are implemented
1562specially in Emacs can be (and usually are) buffer-local, but can never 1578specially in Emacs can be (and usually are) buffer-local, but can never
1563be frame-local. 1579be frame-local.
1580
1581This command returns @var{variable}.
1564@end deffn 1582@end deffn
1565 1583
1566 Buffer-local bindings take precedence over frame-local bindings. Thus, 1584 Buffer-local bindings take precedence over frame-local bindings. Thus,
@@ -1675,7 +1693,11 @@ value of @var{alias-var} changes the value of @var{base-var}.
1675 1693
1676If the @var{docstring} argument is non-@code{nil}, it specifies the 1694If the @var{docstring} argument is non-@code{nil}, it specifies the
1677documentation for @var{alias-var}; otherwise, the alias gets the same 1695documentation for @var{alias-var}; otherwise, the alias gets the same
1678documentation as @var{base-var} has, if any. 1696documentation as @var{base-var} has, if any, unless @var{base-var} is
1697itself an alias, in which case @var{alias-var} gets the documentation
1698of the variable at the end of the chain of aliases.
1699
1700This function returns @var{base-var}.
1679@end defun 1701@end defun
1680 1702
1681@defun indirect-variable variable 1703@defun indirect-variable variable
@@ -1693,8 +1715,10 @@ not defined as an alias, the function returns @var{variable}.
1693(setq bar 2) 1715(setq bar 2)
1694bar 1716bar
1695 @result{} 2 1717 @result{} 2
1718@group
1696foo 1719foo
1697 @result{} 2 1720 @result{} 2
1721@end group
1698(setq foo 0) 1722(setq foo 0)
1699bar 1723bar
1700 @result{} 0 1724 @result{} 0
@@ -1706,7 +1730,9 @@ foo
1706@section File Local Variables 1730@section File Local Variables
1707 1731
1708 This section describes the functions and variables that affect 1732 This section describes the functions and variables that affect
1709processing of local variables lists in files. 1733processing of local variables lists in files. @xref{File variables, ,
1734Local Variables in Files, emacs, The GNU Emacs Manual}, for basic
1735information about file local variables.
1710 1736
1711@defopt enable-local-variables 1737@defopt enable-local-variables
1712This variable controls whether to process file local variables lists. A 1738This variable controls whether to process file local variables lists. A
@@ -1715,13 +1741,19 @@ unconditionally; @code{nil} means ignore them; anything else means ask
1715the user what to do for each file. The default value is @code{t}. 1741the user what to do for each file. The default value is @code{t}.
1716@end defopt 1742@end defopt
1717 1743
1718@defun hack-local-variables &optional force 1744@defun hack-local-variables &optional mode-only
1719This function parses, and binds or evaluates as appropriate, any local 1745This function parses, and binds or evaluates as appropriate, any local
1720variables specified by the contents of the current buffer. The variable 1746variables specified by the contents of the current buffer. The variable
1721@code{enable-local-variables} has its effect here. 1747@code{enable-local-variables} has its effect here. However, this
1722 1748function does not look for the @samp{mode:} local variable in the
1723The argument @var{force} usually comes from the argument @var{find-file} 1749@w{@samp{-*-}} line. @code{set-auto-mode} does that, also taking
1724given to @code{normal-mode}. 1750@code{enable-local-variables} into account.
1751
1752If the optional argument @var{mode-only} is non-@code{nil}, then all
1753this function does is return @code{t} if the @w{@samp{-*-}} line
1754specifies a mode and @code{nil} otherwise. It does not set the mode
1755nor any other file local variable. It does not check whether a mode
1756is specified in the local variables list at the end of the file.
1725@end defun 1757@end defun
1726 1758
1727 If a file local variable list could specify a function that will 1759 If a file local variable list could specify a function that will
@@ -1738,7 +1770,15 @@ you should use such a name whenever it is appropriate for the
1738variable's meaning. The variables @samp{font-lock-keywords}, 1770variable's meaning. The variables @samp{font-lock-keywords},
1739@samp{font-lock-keywords-[0-9]}, and 1771@samp{font-lock-keywords-[0-9]}, and
1740@samp{font-lock-syntactic-keywords} cannot be set in a local variable 1772@samp{font-lock-syntactic-keywords} cannot be set in a local variable
1741list, either. 1773list, either. These rules can be overridden by giving the variable's
1774name a non-@code{nil} @code{safe-local-variable} property. If one
1775gives it a @code{safe-local-variable} property of @code{t}, then one
1776can give the variable any file local value. One can also give any
1777symbol, including the above, a @code{safe-local-variable} property
1778that is a function taking exactly one argument. In that case, giving
1779a variable with that name a file local value is only allowed if the
1780function returns non-@code{nil} when called with that value as
1781argument.
1742 1782
1743 In addition, any variable whose name has a non-@code{nil} 1783 In addition, any variable whose name has a non-@code{nil}
1744@code{risky-local-variable} property is also ignored. So are all 1784@code{risky-local-variable} property is also ignored. So are all
@@ -1750,9 +1790,12 @@ set by a file's local variables list. Any value specified
1750for one of these variables is ignored. 1790for one of these variables is ignored.
1751@end defvar 1791@end defvar
1752 1792
1753@defun risky-local-variable-p sym 1793@defun risky-local-variable-p sym &optional val
1754Returns non-@code{nil} if @var{sym} is risky for any of the reasons 1794If @var{val} is non-@code{nil}, returns non-@code{nil} if giving
1755stated above. 1795@var{sym} a file local value of @var{val} would be risky, for any of
1796the reasons stated above. If @var{val} is @code{nil} or omitted, only
1797returns @code{nil} if @var{sym} can be safely assigned any file local
1798value whatsoever.
1756@end defun 1799@end defun
1757 1800
1758 The @samp{Eval:} ``variable'' is also a potential loophole, so Emacs 1801 The @samp{Eval:} ``variable'' is also a potential loophole, so Emacs