Wednesday, January 30, 2013

Re: ctags processing jumps to wrong tag?

On Wednesday, January 30, 2013 10:35:44 AM UTC-6, Ben Fritz wrote:
>
> After some investigation, the root cause is that ctags by default uses
>
> a search pattern for the tag location. Thus when a function prototype
>
> and definition are spread over multiple lines, and the first line is
>
> the same for each, the tag location in the generated tags file uses an
>
> identical pattern.
>
>
>
> This is somewhat documented (but not explicitly):
>
>
>
> http://ctags.sourceforge.net/ctags.html#CAVEATS
>
>
>
> I see three ways to fix this:
>
>
>
> 1. Modify the file to force a difference between the prototype and
>
> function definition. Not really an option, files I edit are under
>
> strict change control and this would be a fairly pointless edit.
>
> 2. Move the prototypes into a header file. Not an option for the same
>
> reason as (1), and because the problem occurs mostly for "private"
>
> helper functions scoped to the file itself using the static keyword.
>
> 3. Generate tags using line numbers as locations, by adding
>
> --excmd=number to my ctags options. I don't like this method because
>
> then jumping to tags with an older tags file will miss frequently if
>
> the file has changed.
>
>
>
> Is there some unknown fourth option without the drawbacks of (3) that
>
> does not involve modifying the file itself?

I found a reasonable workaround for my uses. Using the -B flag to ctags generation generates backwards search patterns from the end of the file, so always the last occurrence (the function definition) is found instead of always the first (the function prototype). This makes the prototype for these functions inaccessible via tag jumping, but normally I want the function definition anyway so it's less of an issue than the behavior without -B.

> Just generating tags for
>
> prototypes using line numbers but using patterns for the rest of the
>
> tags would be a decent compromise, but I'm not sure how I'd accomplish
>
> that (if it's even possible).
>
>

I realized after some thought that this still wouldn't work, unless I also use backwards search. I may experiment sometime to see if I can generating ONLY prototype tags and append them to a tags file generated without prototypes. Then I could use forward search for prototypes and backwards search for definitions.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: