Previous: , Up: Variables   [Contents][Index]


16.10 Variable Aliases

You can define a variable as an alias for another. Any time you reference the former variable, the current value of the latter is returned. Any time you change the value of the former variable, the value of the latter is actually changed. This is useful in cases where you want to rename a variable but still make old code work (see Obsoleteness).

Function: defvaralias variable alias

This function defines variable as an alias for alias. Thenceforth, any operations performed on variable will actually be performed on alias. Both variable and alias should be symbols. If alias is nil, remove any aliases for variable. alias can itself be aliased, and the chain of variable aliases will be followed appropriately. If variable already has a value, this value will be shadowed until the alias is removed, at which point it will be restored. Currently variable cannot be a built-in variable, a variable that has a buffer-local value in any buffer, or the symbols nil or t.

Function: variable-alias variable &optional follow-past-lisp-magic

If variable is aliased to another variable, this function returns that variable. variable should be a symbol. If variable is not aliased, this function returns nil.

Function: indirect-variable object &optional follow-past-lisp-magic

This function returns the variable at the end of object’s variable-alias chain. If object is a symbol, follow all variable aliases and return the final (non-aliased) symbol. If object is not a symbol, just return it. Signal a cyclic-variable-indirection error if there is a loop in the variable chain of symbols.


Previous: , Up: Variables   [Contents][Index]