Re: tags, functions

2006-06-18 Thread Yegappan Lakshmanan

Hi Yakov,

On 6/18/06, Yakov Lerner <[EMAIL PROTECTED]> wrote:

On 6/18/06, A.J.Mechelynck <[EMAIL PROTECTED]> wrote:
> Yegappan Lakshmanan wrote:
> > Hi Yakov,
> >
> > On 6/18/06, Yakov Lerner <[EMAIL PROTECTED]> wrote:
> >> How can I determine [in vim function] that my current line
> >> number corresponds to the definition of tag X ?
> >>
> >> Do I need to parse tags-file for that, or I can get it using
> >> existing vim functions ?
> >>
> >
> > You need to parse the tags file and use the line numbers stored
> > in the tags file for each tag. If the tags file is sorted, then you can
> > do a binary search. Otherwise you have to do a linear search.
> >
> > You can look at the Tlist_Find_Nearest_Tag_Idx() function in
> > the taglist plugin for an example.
> >
> > http://vim.sourceforge.net/scripts/script.php?script_id=273
> >
> > - Yegappan
> >
> >
>
> The tags file doesn't always have line numbers in it. In many cases
> (such as the Vim help tags files) it has a search command instead.
>
> But what was Yakov asking? "I am moving the cursor, have I arrived at
> the definition for tag foobar?" or "Is there a tag definition, and which
> one, on the current cursor line?" ?

Here is what I'm asknig. I have tag name, X. I want to remap key C-]
so that it remembers tag name in some variable b:tag. The I want some other
mapping that will bring me to *next* definition of "last C-]ed" tag.



The ":tnext" command already supports this and jumps to the next
matching tag definition.

You can use the following commands to browse through multiple
matching tags:

:tnext
:tprevious
:tfirst
:tlast
:tselect
:tjump
:ltag

- Yegappan



I thought the logic can be "check if we are already at some definition of
tag b:tag". If we are, then just to the next definition. But maybe it's not
needed, [to knwo whether we are at the definion", if the next-tag-def
mapping will remember the definition number. Yes, in fact that's all
that's needed. I think I have everything in palce to create the
next-tag-definition mappnig.

Yakov



Re: tags, functions

2006-06-18 Thread A.J.Mechelynck

Yakov Lerner wrote:

On 6/18/06, A.J.Mechelynck <[EMAIL PROTECTED]> wrote:

Yegappan Lakshmanan wrote:
> Hi Yakov,
>
> On 6/18/06, Yakov Lerner <[EMAIL PROTECTED]> wrote:
>> How can I determine [in vim function] that my current line
>> number corresponds to the definition of tag X ?
>>
>> Do I need to parse tags-file for that, or I can get it using
>> existing vim functions ?
>>
>
> You need to parse the tags file and use the line numbers stored
> in the tags file for each tag. If the tags file is sorted, then you can
> do a binary search. Otherwise you have to do a linear search.
>
> You can look at the Tlist_Find_Nearest_Tag_Idx() function in
> the taglist plugin for an example.
>
> http://vim.sourceforge.net/scripts/script.php?script_id=273
>
> - Yegappan
>
>

The tags file doesn't always have line numbers in it. In many cases
(such as the Vim help tags files) it has a search command instead.

But what was Yakov asking? "I am moving the cursor, have I arrived at
the definition for tag foobar?" or "Is there a tag definition, and which
one, on the current cursor line?" ?


Here is what I'm asknig. I have tag name, X. I want to remap key C-]
so that it remembers tag name in some variable b:tag. The I want some other
mapping that will bring me to *next* definition of "last C-]ed" tag.

I thought the logic can be "check if we are already at some definition of
tag b:tag". If we are, then just to the next definition. But maybe it's not
needed, [to knwo whether we are at the definion", if the next-tag-def
mapping will remember the definition number. Yes, in fact that's all
that's needed. I think I have everything in palce to create the
next-tag-definition mappnig.

Yakov




See my original reply to you: Vim already has "get to next/previous 
matching tag", :tn[ext] and :tN[ext] / :tp[revious]



Best regards,
Tony.


Re: tags, functions

2006-06-18 Thread Yakov Lerner

On 6/18/06, A.J.Mechelynck <[EMAIL PROTECTED]> wrote:

Yegappan Lakshmanan wrote:
> Hi Yakov,
>
> On 6/18/06, Yakov Lerner <[EMAIL PROTECTED]> wrote:
>> How can I determine [in vim function] that my current line
>> number corresponds to the definition of tag X ?
>>
>> Do I need to parse tags-file for that, or I can get it using
>> existing vim functions ?
>>
>
> You need to parse the tags file and use the line numbers stored
> in the tags file for each tag. If the tags file is sorted, then you can
> do a binary search. Otherwise you have to do a linear search.
>
> You can look at the Tlist_Find_Nearest_Tag_Idx() function in
> the taglist plugin for an example.
>
> http://vim.sourceforge.net/scripts/script.php?script_id=273
>
> - Yegappan
>
>

The tags file doesn't always have line numbers in it. In many cases
(such as the Vim help tags files) it has a search command instead.

But what was Yakov asking? "I am moving the cursor, have I arrived at
the definition for tag foobar?" or "Is there a tag definition, and which
one, on the current cursor line?" ?


Here is what I'm asknig. I have tag name, X. I want to remap key C-]
so that it remembers tag name in some variable b:tag. The I want some other
mapping that will bring me to *next* definition of "last C-]ed" tag.

I thought the logic can be "check if we are already at some definition of
tag b:tag". If we are, then just to the next definition. But maybe it's not
needed, [to knwo whether we are at the definion", if the next-tag-def
mapping will remember the definition number. Yes, in fact that's all
that's needed. I think I have everything in palce to create the
next-tag-definition mappnig.

Yakov


Re: tags, functions

2006-06-18 Thread A.J.Mechelynck

Yegappan Lakshmanan wrote:

Hi Yakov,

On 6/18/06, Yakov Lerner <[EMAIL PROTECTED]> wrote:

How can I determine [in vim function] that my current line
number corresponds to the definition of tag X ?

Do I need to parse tags-file for that, or I can get it using
existing vim functions ?



You need to parse the tags file and use the line numbers stored
in the tags file for each tag. If the tags file is sorted, then you can
do a binary search. Otherwise you have to do a linear search.

You can look at the Tlist_Find_Nearest_Tag_Idx() function in
the taglist plugin for an example.

http://vim.sourceforge.net/scripts/script.php?script_id=273

- Yegappan




The tags file doesn't always have line numbers in it. In many cases 
(such as the Vim help tags files) it has a search command instead.


But what was Yakov asking? "I am moving the cursor, have I arrived at 
the definition for tag foobar?" or "Is there a tag definition, and which 
one, on the current cursor line?" ?



Best regards,
Tony.


Re: tags, functions

2006-06-18 Thread Yegappan Lakshmanan

Hi Yakov,

On 6/18/06, Yakov Lerner <[EMAIL PROTECTED]> wrote:

How can I determine [in vim function] that my current line
number corresponds to the definition of tag X ?

Do I need to parse tags-file for that, or I can get it using
existing vim functions ?



You need to parse the tags file and use the line numbers stored
in the tags file for each tag. If the tags file is sorted, then you can
do a binary search. Otherwise you have to do a linear search.

You can look at the Tlist_Find_Nearest_Tag_Idx() function in
the taglist plugin for an example.

http://vim.sourceforge.net/scripts/script.php?script_id=273

- Yegappan