emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: defvar inside let-binding


From: Stefan Monnier
Subject: Re: defvar inside let-binding
Date: Tue, 02 Aug 2011 16:47:03 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

>> Yes.  Tho the "next" step you suggested (to cause defvar to change the
>> outer let-binding) will require another such function and will make
>> symbol-let-bound-p unneeded.

> Let's see...

>   ;; Use defvar to set the docstring as well as the special-variable-p flag.
>   ;; FIXME: We should reproduce more of `defvar's behavior, such as the 
> warning
>   ;; when the var is currently let-bound.
>   (if (not (default-boundp symbol))
>       ;; Don't use defvar to avoid setting a default-value when undesired.
>       (when doc (put symbol 'variable-documentation doc))
>     (eval `(defvar ,symbol nil ,@(when doc (list doc)))))

> So what I would do here now would be to add

> (when (symbol-let-bound-p symbol)
>   (message "Warning: let-bound etc"))

> now, and in Emacs 24.2, I'd change that to

> (when (symbol-let-bound-p symbol)
>   (change-outer-let-binding symbol default))

> Or something along those lines?  

Yes, although the above code is run after the var has been set,
i.e. too late.


        Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]