changeset 37732:f98176963881

(Fdefvar): Only record (defvar <var>) in the load-history in <var> has no default value yet.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Mon, 14 May 2001 20:52:07 +0000
parents 7c313c4b3eba
children 2d969f61e620
files src/eval.c
diffstat 1 files changed, 18 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/eval.c	Mon May 14 17:52:12 2001 +0000
+++ b/src/eval.c	Mon May 14 20:52:07 2001 +0000
@@ -686,21 +686,28 @@
   if (!NILP (Fcdr (Fcdr (tail))))
     error ("too many arguments");
 
+  tem = Fdefault_boundp (sym);
   if (!NILP (tail))
     {
-      tem = Fdefault_boundp (sym);
       if (NILP (tem))
-	Fset_default (sym, Feval (Fcar (Fcdr (args))));
+	Fset_default (sym, Feval (Fcar (tail)));
+      tail = Fcdr (tail);
+      if (!NILP (Fcar (tail)))
+	{
+	  tem = Fcar (tail);
+	  if (!NILP (Vpurify_flag))
+	    tem = Fpurecopy (tem);
+	  Fput (sym, Qvariable_documentation, tem);
+	}
+      LOADHIST_ATTACH (sym);
     }
-  tail = Fcdr (Fcdr (args));
-  if (!NILP (Fcar (tail)))
-    {
-      tem = Fcar (tail);
-      if (!NILP (Vpurify_flag))
-	tem = Fpurecopy (tem);
-      Fput (sym, Qvariable_documentation, tem);
-    }
-  LOADHIST_ATTACH (sym);
+  else
+    /* A (defvar <var>) should not take precedence in the load-history over
+       an earlier (defvar <var> <val>), so only add to history if the default
+       value is still unbound.  */
+    if (NILP (tem))
+      LOADHIST_ATTACH (sym);
+    
   return sym;
 }