martin rudalics wrote:
The beg/start dichotomy might also explain why INDEX-POSITION
occasionally gets me to a rather strange place: `java-mode', for
example, seems to prefer a position two characters before the end of the
keyword preceding the listed identifier - something like "vo-!-id" or
"Stri-!-ng".  If there's no such keyword the first suitable character
string is used and I might find myself in a preceding comment.
`cperl-mode', on the other hand, puts me at the _end_ of the identifier
listed by imenu.

I didn't see why at first, but it makes sense after some investigation. imenu uses `re-search-backward' to find identifiers. The java-mode regex (`cc-imenu-java-generic-expression') matches a typespec using "[a-zA-Z_][\]\[.a-zA-Z0-9_]+", which makes sense when you're searching forwards. But since a backwards re-search stops at the first match CLOSEST to point, that `+' operator effectively becomes non-greedy. In this case, the last two characters of anything typespec-ish will match that regex -- even if that thing is at the end of a preceding single-line comment.

Regardless, Richard's fix does The Right Thing (TM), and you'll always find 
yourself at the start of the line containing the identifier.

(On a related note, any regex junkies want to take a crack at the c-mode regex(es)?  Some 
of those "identifiers" found in abbrev.c are buried in comments.)

-Dave



_______________________________________________
Emacs-pretest-bug mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug

Reply via email to