Subject: bug#8638: 24.0.50; Imenu should not include vacuous defvars

From: Stefan Monnier <[email-masked]>
Date: Mon, 09 May 2011 11:19:34 -0300

>> Could we please improve `lisp-imenu-generic-expression so that it does
>> not include vacuous defvars such as (defvar foobar), which are generally
>> used only to quiet the byte-compiler?
> With lexical binding, (defvar foobar) is used to tell the bytecompiler
> that the variable has dynamic scope.

While it is true some some (defvar <foo>) are actually declarations that
<foo> is a locally-used dynamically bound variable (in which case,
maybe it could make sense to see it in imenu), the overwhelming
majority is to declare the existence of some variable in some other
package, in which case I don't think it deserves to be in imenu.
And even when it might make sense, its usefulness seems dubious since
those defvars don't hold much valuable info (like initial value,
docstring, or something).
So I'd tend to agree with Drew.  For completion purposes, we'd want to
pay attention to those defvars, but not for imenu.

        Stefan