diff options
| author | Gerd Moellmann | 2001-10-05 09:38:43 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2001-10-05 09:38:43 +0000 |
| commit | 26236f6d9c903a219fb1a1000f7fce17cc2bf5c3 (patch) | |
| tree | d6d1c98a186ce59446c796c44301d2e4532953ba | |
| parent | 74ac24674bad27b674ab28f1bd1efc1cc1f5da5b (diff) | |
| download | emacs-26236f6d9c903a219fb1a1000f7fce17cc2bf5c3.tar.gz emacs-26236f6d9c903a219fb1a1000f7fce17cc2bf5c3.zip | |
(Variable Aliases): New node.
| -rw-r--r-- | lispref/variables.texi | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/lispref/variables.texi b/lispref/variables.texi index 5b981013708..097961e98bd 100644 --- a/lispref/variables.texi +++ b/lispref/variables.texi | |||
| @@ -41,6 +41,7 @@ variable. | |||
| 41 | * Buffer-Local Variables:: Variable values in effect only in one buffer. | 41 | * Buffer-Local Variables:: Variable values in effect only in one buffer. |
| 42 | * Frame-Local Variables:: Variable values in effect only in one frame. | 42 | * Frame-Local Variables:: Variable values in effect only in one frame. |
| 43 | * Future Local Variables:: New kinds of local values we might add some day. | 43 | * Future Local Variables:: New kinds of local values we might add some day. |
| 44 | * Variable Aliases:: Variables that are aliases for other variables. | ||
| 44 | * File Local Variables:: Handling local variable lists in files. | 45 | * File Local Variables:: Handling local variable lists in files. |
| 45 | @end menu | 46 | @end menu |
| 46 | 47 | ||
| @@ -1654,6 +1655,48 @@ bindings offer a way to handle these situations more robustly. | |||
| 1654 | If sufficient application is found for either of these two kinds of | 1655 | If sufficient application is found for either of these two kinds of |
| 1655 | local bindings, we will provide it in a subsequent Emacs version. | 1656 | local bindings, we will provide it in a subsequent Emacs version. |
| 1656 | 1657 | ||
| 1658 | @node Variable Aliases | ||
| 1659 | @section Variable Aliases | ||
| 1660 | |||
| 1661 | It is sometimes useful to make two variables synonyms, so that both | ||
| 1662 | variables always have the same value, and changing either one also | ||
| 1663 | changes the other. Whenever you change the name of a | ||
| 1664 | variable---either because you realize its old name was not well | ||
| 1665 | chosen, or because its meaning has partly changed---it can be useful | ||
| 1666 | to keep the old name as an @emph{alias} of the new one for | ||
| 1667 | compatibility. You can do this with @code{defvaralias}. | ||
| 1668 | |||
| 1669 | @defmacro defvaralias alias-var base-var | ||
| 1670 | This function defines the symbol @var{alias-var} as a variable alias | ||
| 1671 | for symbol @var{base-var}. This means that retrieving the value of | ||
| 1672 | @var{alias-var} returns the value of @var{base-var}, and changing the | ||
| 1673 | value of @var{alias-var} changes the value of @var{base-var}. | ||
| 1674 | @end defmacro | ||
| 1675 | |||
| 1676 | @defun indirect-variable variable | ||
| 1677 | This function returns the variable at the end of the chain of aliases | ||
| 1678 | of @var{variable}. If @var{variable} is not a symbol, or if @var{variable} is | ||
| 1679 | not defined as an alias, the function returns @var{variable}. | ||
| 1680 | @end defun | ||
| 1681 | |||
| 1682 | @example | ||
| 1683 | (defvaralias 'foo 'bar) | ||
| 1684 | (indirect-variable 'foo) | ||
| 1685 | @result{} bar | ||
| 1686 | (indirect-variable 'bar) | ||
| 1687 | @result{} bar | ||
| 1688 | (setq bar 2) | ||
| 1689 | bar | ||
| 1690 | @result{} 2 | ||
| 1691 | foo | ||
| 1692 | @result{} 2 | ||
| 1693 | (setq foo 0) | ||
| 1694 | bar | ||
| 1695 | @result{} 0 | ||
| 1696 | foo | ||
| 1697 | @result{} 0 | ||
| 1698 | @end example | ||
| 1699 | |||
| 1657 | @node File Local Variables | 1700 | @node File Local Variables |
| 1658 | @section File Local Variables | 1701 | @section File Local Variables |
| 1659 | 1702 | ||