Mercurial > emacs
comparison lispref/variables.texi @ 39571:9b87a63bcb36
(Variable Aliases): New node.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Fri, 05 Oct 2001 09:38:43 +0000 |
parents | 27db1f1aac19 |
children | 7f0c5b8c1f41 |
comparison
equal
deleted
inserted
replaced
39570:d16a58a98f40 | 39571:9b87a63bcb36 |
---|---|
39 * Setting Variables:: Storing new values in variables. | 39 * Setting Variables:: Storing new values in variables. |
40 * Variable Scoping:: How Lisp chooses among local and global values. | 40 * Variable Scoping:: How Lisp chooses among local and global values. |
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 |
47 @node Global Variables | 48 @node Global Variables |
48 @section Global Variables | 49 @section Global Variables |
1652 bindings offer a way to handle these situations more robustly. | 1653 bindings offer a way to handle these situations more robustly. |
1653 | 1654 |
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 |
1660 This section describes the functions and variables that affect | 1703 This section describes the functions and variables that affect |
1661 processing of local variables lists in files. | 1704 processing of local variables lists in files. |