Reputation: 3745
The first tip in Warning Tips - GNU Emacs Lisp Reference Manual:
Try to avoid compiler warnings about undefined free variables, by adding dummy defvar definitions for these variables, like this: (defvar foo) Such a definition has no effect except to tell the compiler not to warn about uses of the variable foo in this file.
What is a scenario where someone would want no effect and yet want to disable the warning about the free variable? Whenever I got warnings about undefined free variables, it was always the case that either I forgot to put (defvar foo initvalue docstring)
or I misspelled a local variable name.
Upvotes: 2
Views: 136
Reputation: 30701
Your question is why/when to suppress such warnings. The answer is: in either of these situations:
The variable is defined elsewhere, and you know that the library defining it will be loaded before the code actually tries to use the variable.
You want to declare that the variable is a "special" variable, that is, it is to be bound dynamically, not lexically.
Upvotes: 2