The attached patch makes Imenu ignore definitions that are in invisible text. This is especially useful when combined with code that hides comments, in which case definitions that are commented out are not included in the Imenu. (Obviously, that behavior should be optional, as it is sometimes helpful to use Imenu to get to commented-out definitions too.) Someone else might have a more elegant or more performant way to do this, but this way seems to work OK. In GNU Emacs 24.0.91.1 (i386-mingw-nt5.1.2600) of 2011-11-21 on MARVIN Windowing system distributor `Microsoft Corp.', version 5.1.2600 configured using `configure --with-gcc (4.6) --no-opt --cflags -ID:/devel/emacs/libs/libXpm-3.5.8/include -ID:/devel/emacs/libs/libXpm-3.5.8/src -ID:/devel/emacs/libs/libpng-dev_1.4.3-1/include -ID:/devel/emacs/libs/zlib-dev_1.2.5-2/include -ID:/devel/emacs/libs/giflib-4.1.4-1/include -ID:/devel/emacs/libs/jpeg-6b-4/include -ID:/devel/emacs/libs/tiff-3.8.2-1/include -ID:/devel/emacs/libs/gnutls-2.10.1/include --ldflags -LD:/devel/emacs/libs/gnutls-2.10.1/lib'