diff options
| author | Stefan Monnier | 2004-11-22 05:26:50 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2004-11-22 05:26:50 +0000 |
| commit | d0bce91e9c99cc5a62e775a3d5eb79af8a28d34f (patch) | |
| tree | 3e7dc4d3694be3bad6dbb50fe44ec8cfada89085 /src/eval.c | |
| parent | 87ae59e3680c70b7e284c0458c29cf5bc65d39ad (diff) | |
| download | emacs-d0bce91e9c99cc5a62e775a3d5eb79af8a28d34f.tar.gz emacs-d0bce91e9c99cc5a62e775a3d5eb79af8a28d34f.zip | |
(Fdefvar): Warn when var is let-bound but globally void.
Diffstat (limited to 'src/eval.c')
| -rw-r--r-- | src/eval.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/eval.c b/src/eval.c index adff3e8670c..e8a8e4668e4 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -786,6 +786,21 @@ usage: (defvar SYMBOL &optional INITVALUE DOCSTRING) */) | |||
| 786 | { | 786 | { |
| 787 | if (NILP (tem)) | 787 | if (NILP (tem)) |
| 788 | Fset_default (sym, Feval (Fcar (tail))); | 788 | Fset_default (sym, Feval (Fcar (tail))); |
| 789 | else | ||
| 790 | { /* Check if there is really a global binding rather than just a let | ||
| 791 | binding that shadows the global unboundness of the var. */ | ||
| 792 | struct specbinding *pdl = specpdl_ptr; | ||
| 793 | while (--pdl >= specpdl) | ||
| 794 | { | ||
| 795 | if (EQ (pdl->symbol, sym) && !pdl->func | ||
| 796 | && EQ (pdl->old_value, Qunbound)) | ||
| 797 | { | ||
| 798 | message_with_string ("Warning: defvar ignored because %s is let-bound", | ||
| 799 | SYMBOL_NAME (sym), 1); | ||
| 800 | break; | ||
| 801 | } | ||
| 802 | } | ||
| 803 | } | ||
| 789 | tail = Fcdr (tail); | 804 | tail = Fcdr (tail); |
| 790 | tem = Fcar (tail); | 805 | tem = Fcar (tail); |
| 791 | if (!NILP (tem)) | 806 | if (!NILP (tem)) |