aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGlenn Morris <[email protected]>2008-04-11 03:41:34 +0000
committerGlenn Morris <[email protected]>2008-04-11 03:41:34 +0000
commitdd60787c17d597393026cd2116b9c10f10d26aad (patch)
tree62821ed3ae842a0b81e3bb0e09f38da386ae80dc /src
parent532a0f4c95ef7773e706044552b69bed77c7816b (diff)
(Fdefvaralias): If the alias is bound and the target is not, set the
target's value to that of the alias.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog5
-rw-r--r--src/eval.c13
2 files changed, 15 insertions, 3 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 385fe3005c..1bdc540144 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2008-04-11 Glenn Morris <[email protected]>
+
+ * eval.c (Fdefvaralias): If the alias is bound and the target is not,
+ set the target's value to that of the alias.
+
2008-04-11 Stefan Monnier <[email protected]>
* term.c (set_tty_color_mode): Left over typo.
diff --git a/src/eval.c b/src/eval.c
index 62fe01592e..eca46424da 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -772,9 +772,10 @@ DEFUN ("defvaralias", Fdefvaralias, Sdefvaralias, 2, 3, 0,
doc: /* Make NEW-ALIAS a variable alias for symbol BASE-VARIABLE.
Aliased variables always have the same value; setting one sets the other.
Third arg DOCSTRING, if non-nil, is documentation for NEW-ALIAS. If it is
- omitted or nil, NEW-ALIAS gets the documentation string of BASE-VARIABLE,
- or of the variable at the end of the chain of aliases, if BASE-VARIABLE is
- itself an alias.
+omitted or nil, NEW-ALIAS gets the documentation string of BASE-VARIABLE,
+or of the variable at the end of the chain of aliases, if BASE-VARIABLE is
+itself an alias. If NEW-ALIAS is bound, and BASE-VARIABLE is not,
+then the value of BASE-VARIABLE is set to that of NEW-ALIAS.
The return value is BASE-VARIABLE. */)
(new_alias, base_variable, docstring)
Lisp_Object new_alias, base_variable, docstring;
@@ -788,6 +789,12 @@ The return value is BASE-VARIABLE. */)
error ("Cannot make a constant an alias");
sym = XSYMBOL (new_alias);
+ /* http://lists.gnu.org/archive/html/emacs-devel/2008-04/msg00834.html
+ If n_a is bound, but b_v is not, set the value of b_v to n_a.
+ This is for the sake of define-obsolete-variable-alias and user
+ customizations. */
+ if (NILP (Fboundp (base_variable)) && !NILP (Fboundp (new_alias)))
+ XSYMBOL(base_variable)->value = sym->value;
sym->indirect_variable = 1;
sym->value = base_variable;
sym->constant = SYMBOL_CONSTANT_P (base_variable);