help-gnu-emacs
[Top][All Lists]
Advanced

[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: Tassilo Horn
Subject: Re: How do I remove "reference to free variable" warnings on buffer-local variables?
Date: Mon, 09 Nov 2009 17:45:14 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux)

rocky <address@hidden> writes:

> 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?

This warning indicates, that this variable isn't defvar-ed somewhere in
the code you are compiling.  But you can supress those like it's stated
in the manual:

,----[ (info "(elisp)Compiler Errors") ]
|    You can tell the compiler that a function is defined using
| `declare-function' (*note Declaring Functions::).  Likewise, you can
| tell the compiler that a variable is defined using `defvar' with no
| initial value.
| 
|    You can suppress the compiler warning for a specific use of an
| undefined variable VARIABLE by conditionalizing its use on a `boundp'
| test, like this:
| 
|      (if (boundp 'VARIABLE) ...VARIABLE...)
`----

So in your case you could add something like

  (or (boundp 'some-variable) (defvar some-variable))

at the top of your file.

HTH,
Tassilo





reply via email to

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