comparison src/data.c @ 108005:734b50109edf

Warn rather than error when making a local var inside a let. * data.c (Fmake_variable_buffer_local, Fmake_local_variable): Just signal a warning rather than an error when inside a let. (Fmake_variable_frame_local): Add the same test.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Tue, 20 Apr 2010 13:35:16 -0400
parents bef5d1738c0b
children 150fd3d78f5a
comparison
equal deleted inserted replaced
108004:9d210d83ed69 108005:734b50109edf
1637 SET_SYMBOL_BLV (sym, blv); 1637 SET_SYMBOL_BLV (sym, blv);
1638 { 1638 {
1639 Lisp_Object symbol; 1639 Lisp_Object symbol;
1640 XSETSYMBOL (symbol, sym); /* In case `variable' is aliased. */ 1640 XSETSYMBOL (symbol, sym); /* In case `variable' is aliased. */
1641 if (let_shadows_global_binding_p (symbol)) 1641 if (let_shadows_global_binding_p (symbol))
1642 error ("Making %s buffer-local while let-bound!", 1642 message ("Making %s buffer-local while let-bound!",
1643 SDATA (SYMBOL_NAME (variable))); 1643 SDATA (SYMBOL_NAME (variable)));
1644 } 1644 }
1645 } 1645 }
1646 1646
1647 blv->local_if_set = 1; 1647 blv->local_if_set = 1;
1648 return variable; 1648 return variable;
1700 break; 1700 break;
1701 default: abort (); 1701 default: abort ();
1702 } 1702 }
1703 1703
1704 if (sym->constant) 1704 if (sym->constant)
1705 error ("Symbol %s may not be buffer-local", SDATA (SYMBOL_NAME (variable))); 1705 error ("Symbol %s may not be buffer-local",
1706 SDATA (SYMBOL_NAME (variable)));
1706 1707
1707 if (blv ? blv->local_if_set 1708 if (blv ? blv->local_if_set
1708 : (forwarded && BUFFER_OBJFWDP (valcontents.fwd))) 1709 : (forwarded && BUFFER_OBJFWDP (valcontents.fwd)))
1709 { 1710 {
1710 tem = Fboundp (variable); 1711 tem = Fboundp (variable);
1720 SET_SYMBOL_BLV (sym, blv); 1721 SET_SYMBOL_BLV (sym, blv);
1721 { 1722 {
1722 Lisp_Object symbol; 1723 Lisp_Object symbol;
1723 XSETSYMBOL (symbol, sym); /* In case `variable' is aliased. */ 1724 XSETSYMBOL (symbol, sym); /* In case `variable' is aliased. */
1724 if (let_shadows_global_binding_p (symbol)) 1725 if (let_shadows_global_binding_p (symbol))
1725 error ("Making %s local to %s while let-bound!", 1726 message ("Making %s local to %s while let-bound!",
1726 SDATA (SYMBOL_NAME (variable)), SDATA (current_buffer->name)); 1727 SDATA (SYMBOL_NAME (variable)),
1728 SDATA (current_buffer->name));
1727 } 1729 }
1728 } 1730 }
1729 1731
1730 /* Make sure this buffer has its own value of symbol. */ 1732 /* Make sure this buffer has its own value of symbol. */
1731 XSETSYMBOL (variable, sym); /* Update in case of aliasing. */ 1733 XSETSYMBOL (variable, sym); /* Update in case of aliasing. */
1897 1899
1898 blv = make_blv (sym, forwarded, valcontents); 1900 blv = make_blv (sym, forwarded, valcontents);
1899 blv->frame_local = 1; 1901 blv->frame_local = 1;
1900 sym->redirect = SYMBOL_LOCALIZED; 1902 sym->redirect = SYMBOL_LOCALIZED;
1901 SET_SYMBOL_BLV (sym, blv); 1903 SET_SYMBOL_BLV (sym, blv);
1904 {
1905 Lisp_Object symbol;
1906 XSETSYMBOL (symbol, sym); /* In case `variable' is aliased. */
1907 if (let_shadows_global_binding_p (symbol))
1908 message ("Making %s frame-local while let-bound!",
1909 SDATA (SYMBOL_NAME (variable)));
1910 }
1902 return variable; 1911 return variable;
1903 } 1912 }
1904 1913
1905 DEFUN ("local-variable-p", Flocal_variable_p, Slocal_variable_p, 1914 DEFUN ("local-variable-p", Flocal_variable_p, Slocal_variable_p,
1906 1, 2, 0, 1915 1, 2, 0,