[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How do I remove "reference to free variable" warnings on buffer-loca
From: |
Stefan Monnier |
Subject: |
Re: How do I remove "reference to free variable" warnings on buffer-local variables? |
Date: |
Wed, 11 Nov 2009 00:09:33 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) |
> I have code that uses buffer local variables. I don't want to declare
> this variable global. So how can I remove messages of the form
> "reference to free variable `...' " when I byte compile a file?
There is a special use of defvar designed specifically for that
situation:
(defvar <my-var-here>)
this will have no effect other than silence the byte-compiler.
Stefan
PS: If you really really want to, you can put it inside
`eval-when-compile', in which case it may currently work by accident,
but it logically shouldn't work (and may not work in the future) since
(defvar <foo>) does nothing when evaluated, and `eval-when-compile' asks
the byte-compiler to eval its argument instead of byte-compiling it.