aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2016-12-26 19:10:49 +0200
committerEli Zaretskii2016-12-26 19:10:49 +0200
commitd7973e808d54f1adf5224589c5cf770bb17453d2 (patch)
tree07bdabeaafff0cf5c674f2c0d6cd2d809e1d204d
parent8b7182626e3dac556d1fc38a1193e7d5e386488e (diff)
downloademacs-d7973e808d54f1adf5224589c5cf770bb17453d2.tar.gz
emacs-d7973e808d54f1adf5224589c5cf770bb17453d2.zip
Document 'default-toplevel-value' and 'set-default-toplevel-value'
* doc/lispref/variables.texi (Default Value): Document 'default-toplevel-value' and 'set-default-toplevel-value'.
-rw-r--r--doc/lispref/variables.texi38
1 files changed, 38 insertions, 0 deletions
diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi
index ba31f856369..e231cbdfec1 100644
--- a/doc/lispref/variables.texi
+++ b/doc/lispref/variables.texi
@@ -1580,6 +1580,44 @@ an ordinary evaluated argument.
1580@end example 1580@end example
1581@end defun 1581@end defun
1582 1582
1583 A variable can be let-bound (@pxref{Local Variables}) to a
1584non-default value; in that case, @code{default-value} will return the
1585value from that binding, not the global value, and @code{set-default}
1586will be prevented from setting the global value. The following two
1587functions allow to reference the global value even if it's masked by a
1588let-binding.
1589
1590@cindex top-level default value
1591@defun default-toplevel-value symbol
1592This function returns the @dfn{top-level} default value of
1593@var{symbol}, which is its value outside of any let-binding.
1594@end defun
1595
1596@example
1597@group
1598(defvar variable 'global-value)
1599 @result{} variable
1600@end group
1601@group
1602(let ((variable 'let-binding))
1603 (default-value 'variable))
1604 @result{} let-binding
1605@end group
1606@group
1607(let ((variable 'let-binding))
1608 (default-toplevel-value 'variable))
1609 @result{} global-value
1610@end group
1611@end example
1612
1613@defun set-default-toplevel-value symbol value
1614This function sets the top-level default value of @var{symbol} to the
1615specified @var{value}. This comes in handy when you want to set the
1616global value of @var{symbol} regardless of whether your code runs in
1617the context of @var{symbol}'s let-binding.
1618@end defun
1619
1620
1583@node File Local Variables 1621@node File Local Variables
1584@section File Local Variables 1622@section File Local Variables
1585@cindex file local variables 1623@cindex file local variables