emacs-devel
[Top][All Lists]
Advanced

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

Re: Defvar not called at top level


From: Arthur Miller
Subject: Re: Defvar not called at top level
Date: Wed, 24 Nov 2021 11:47:16 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> Arthur Miller [2021-11-23 14:28:04] wrote:
>> Just a question: why is it important to call defvar from top level?
>> I would like to have some code that generates some other code, amongs that to
>> declare few global symbols with auto generated docs as well.
>
> Presumably you can do this with
>
>     (defmacro FOO (..) ... `(defvar ...) ...)
>
>     (FOO ...)
>
>> If I call those from a defun/macro normally I get that warning that defvar is
>> not called at top level;
>
> Can you show the actual warning?


Thank you for the answer; it seems like I can't :).

I am sorry, I had too many things in my head and confused things. It was not
"defvar" it was "defvar-local". I appologize.

This one:

(defun byte-compile-make-variable-buffer-local (form)
  (if (and (eq (car-safe (car-safe (cdr-safe form))) 'quote)
           (byte-compile-warning-enabled-p 'make-local))
      (byte-compile-warn
       "`make-variable-buffer-local' not called at toplevel"))
  (byte-compile-normal-call form))

I copy-pasted a bunch of defvar-local statements somewhere into a
defun to save some typing; and I got that warning, so I have put them back. By
the way after second thought I think I understand why it could be bad thing, but
I am not sure: if a form would be evaluated in a non-buffer context?



reply via email to

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