diff options
| author | Eli Zaretskii | 2016-12-26 19:10:49 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2016-12-26 19:10:49 +0200 |
| commit | d7973e808d54f1adf5224589c5cf770bb17453d2 (patch) | |
| tree | 07bdabeaafff0cf5c674f2c0d6cd2d809e1d204d | |
| parent | 8b7182626e3dac556d1fc38a1193e7d5e386488e (diff) | |
| download | emacs-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.texi | 38 |
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 | ||
| 1584 | non-default value; in that case, @code{default-value} will return the | ||
| 1585 | value from that binding, not the global value, and @code{set-default} | ||
| 1586 | will be prevented from setting the global value. The following two | ||
| 1587 | functions allow to reference the global value even if it's masked by a | ||
| 1588 | let-binding. | ||
| 1589 | |||
| 1590 | @cindex top-level default value | ||
| 1591 | @defun default-toplevel-value symbol | ||
| 1592 | This 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 | ||
| 1614 | This function sets the top-level default value of @var{symbol} to the | ||
| 1615 | specified @var{value}. This comes in handy when you want to set the | ||
| 1616 | global value of @var{symbol} regardless of whether your code runs in | ||
| 1617 | the 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 |