[comp.emacs] finding right tag out of many

kupfer@orc.olivetti.com (Mike Kupfer) (04/26/89)

I just had the unhappy experience of looking for "get" in some kernel
sources.  There were 155 tags matching "get", and the one I wanted was
around the 130th.  Slogging through the other entries with C-u M-. was
not a great deal of fun.  Is there some clever use of the (GNU Emacs)
tags package that would avoid this, or is it time to make the find-tag
smarter (e.g., by first looking for an "exact" match)?


Mike Kupfer		kupfer@orc.olivetti.com		415-496-6238
{decwrl!oli-stl, ames!oli-stl, oliveb}!orc!kupfer	ucbvax!kupfer

jr@bbn.com (John Robinson) (04/26/89)

In article <41011@oliveb.olivetti.com>, kupfer@orc (Mike Kupfer) writes:
>I just had the unhappy experience of looking for "get" in some kernel
>sources.  There were 155 tags matching "get", and the one I wanted was
>around the 130th.  Slogging through the other entries with C-u M-. was
>not a great deal of fun.  Is there some clever use of the (GNU Emacs)
>tags package that would avoid this, or is it time to make the find-tag
>smarter (e.g., by first looking for an "exact" match)?

You can go a long way by changing find-tag to call re-search-forward
instead of search-forward.  Once you do this, you have to know the
structure of TAGS files to really do what you want, but it isn't that
hard to learn.

Once having done this, you might want to add more cleverness to
find-tag so it always manages NOT to match in the tag location info.

find-tag-exactly could probably work simply by surrounding your tag in
\W escapes, except that this might match "get_" forms.  You can either
change the character syntax of _ temporarily, or know that it is
sufficient to look for "^get " (for a C function) or " get " for a
lisp defun...

A sexier approach might be to use occur-menu on the TAGS file itself;
then you would need a (find-TAGS-tag) function to jump from the tag
you wanted (in the TAGS file) to its place in the source.  Or better
would be to combine them into a tags-occur-menu.  Any volunteers?
--

/jr
jr@bbn.com or bbn!jr
C'mon big money!

weiner@novavax.UUCP (Bob Weiner) (04/28/89)

In article <41011@oliveb.olivetti.com> kupfer@orc.olivetti.com (Mike Kupfer) writes:

   I just had the unhappy experience of looking for "get" in some kernel
   sources.  There were 155 tags matching "get", and the one I wanted was
   around the 130th.  Slogging through the other entries with C-u M-. was
   not a great deal of fun.  Is there some clever use of the (GNU Emacs)
   tags package that would avoid this, or is it time to make the find-tag
   smarter (e.g., by first looking for an "exact" match)?

Look at your TAGS file, then you can do matches that match closely what
is in there, e.g. (defun get, you could also try adding a space before
and after get, even though none of this does exactly what you want.

Try M-, for repeating tags searches.  It works perfectly for me at GNU
Emacs 18.52, though it is not documented as working in this way in the
manual.  Possibly an ommission.
-- 
Bob Weiner, Motorola, Inc.,   USENET:  ...!gatech!uflorida!novavax!weiner
(407) 738-2087