tagselec(), like taglist()

classic Classic list List threaded Threaded
19 messages Options
Reply | Threaded
Open this post in threaded view
|

tagselec(), like taglist()

Hari Krishna Dara

I just downloaded Vim7 alpha version for W32 (thanks to Tony Mechelynck
for making it available) and wanted to check out the new taglist()
function that was added. The purpose of this function, as I can see is
to make it easier to lookup tags for plugins, which is very good. But
I don't see anything equivalent to having a tag selected from the list.
In a typical scenario, say a plugin needs do the below (this is actually
what I do in my tagselect.vim plugin, but I would imagine this to be the
same for most clients of taglist() function):

- Accept a tag-expression from user.
- Get the list of all matching tags using taglist() function.
- Show the list to user properly formatted.
- Allow the user to select one.
- Make vim jump to the selected tag.

It is the last step that is not currently possible, and I was hoping to
see a tagselect({expr}, tagIndex) function available. Without this
function, there are a couple of workarounds that you can do, but they
are not nice:

- Jump to the first tag using :ta command, and use :tn with the right
  count. The reason I don't like this is for the fact that it loads a
  file unnecessarily, and since the tag order may not be exactly the
  same everytime, it might continue to load a new file everytime you
  select a different index.
- The second workaround avoids the above problem, but it is not pretty.
  This workaround actually came from Bram sometime back when I posed
  this question. It involves running :ts along with the selection index
  from a map. Something like this:

    set nomore
    nnoremap <F12> :ts {tag-expr}<CR>{tag-index}<CR>
    exec "normal \<F12>"
    set more

  We are creating a temporary map and executing it. The problem with
  this is that the entire list of matching tags (possibly several
  hundred) will scroll in front of you, before the selection happens.
  The classic way of solving such issues is to prefix the command with
  :silent, but sadly, in this case it causes the map to fail.

I am actually using the second method in my tagselect.vim plugin. I
really like the extra convenience that I am getting from tagselect.vim
in choosing a tag, when there are at least a few 10's of hits for the
tag-expression, but when there are many more hits, the extra convenience
is defeated by the lengthy scrolling that happens (which is worse if I
am on slow connection, such as VPN). Can I request that the tagselect()
function be added to vim7, or at least make the 2nd workaround above to
work when used with :silent command?

--
Sincerely,
Hari


               
__________________________________
Do you Yahoo!?
Read only the mail you want - Yahoo! Mail SpamGuard.
http://promotions.yahoo.com/new_mail 
Reply | Threaded
Open this post in threaded view
|

Re: tagselec(), like taglist()

Yegappan Lakshmanan
Hi Hari,

On 7/21/05, Hari Krishna Dara <[hidden email]> wrote:
>
> I just downloaded Vim7 alpha version for W32 (thanks to Tony Mechelynck
> for making it available) and wanted to check out the new taglist()
> function that was added. The purpose of this function, as I can see is
> to make it easier to lookup tags for plugins, which is very good. But
> I don't see anything equivalent to having a tag selected from the list.
>

>
> - Accept a tag-expression from user.
> - Get the list of all matching tags using taglist() function.
> - Show the list to user properly formatted.
> - Allow the user to select one.
> - Make vim jump to the selected tag.
>

You can use the setqflist() function to create a quickfix list with the
matching tags returned by the taglist() function. The user can now
browse the matching tags using the quickfix window.

In one of the upcoming Vim7 snapshots, the ":qtag" command
(or an equivalent command) will be available. This command will
create a quickfix list with all the matching tags.

- Yegappan
Reply | Threaded
Open this post in threaded view
|

Re: tagselec(), like taglist()

Hari Krishna Dara
In reply to this post by Hari Krishna Dara

On Thu, 21 Jul 2005 at 4:37pm, Yegappan Lakshmanan wrote:

> Hi Hari,
>
> On 7/21/05, Hari Krishna Dara <[hidden email]> wrote:
> >
> > I just downloaded Vim7 alpha version for W32 (thanks to Tony Mechelynck
> > for making it available) and wanted to check out the new taglist()
> > function that was added. The purpose of this function, as I can see is
> > to make it easier to lookup tags for plugins, which is very good. But
> > I don't see anything equivalent to having a tag selected from the list.
> >
>
> >
> > - Accept a tag-expression from user.
> > - Get the list of all matching tags using taglist() function.
> > - Show the list to user properly formatted.
> > - Allow the user to select one.
> > - Make vim jump to the selected tag.
> >
>
> You can use the setqflist() function to create a quickfix list with the
> matching tags returned by the taglist() function. The user can now
> browse the matching tags using the quickfix window.
>
> In one of the upcoming Vim7 snapshots, the ":qtag" command
> (or an equivalent command) will be available. This command will
> create a quickfix list with all the matching tags.
>
> - Yegappan
>
>

They are going to be useful, but I still think there is a need for a
tagselect() function. Using quickfix window should not be the only
option, and having the function gives scope for plugins to enhance or
add any missing built-in functionality. The origin of the call need not
always be from a tag-selection window (say the index is predetermined),
then there is no use for forcing a quickfix window on the user.

--
Thank you,
Hari


               
____________________________________________________
Start your day with Yahoo! - make it your home page
http://www.yahoo.com/r/hs 
 
Reply | Threaded
Open this post in threaded view
|

Re: tagselec(), like taglist()

Bram Moolenaar
In reply to this post by Hari Krishna Dara

Hari Krishna Dara wrote:

> I just downloaded Vim7 alpha version for W32 (thanks to Tony Mechelynck
> for making it available) and wanted to check out the new taglist()
> function that was added. The purpose of this function, as I can see is
> to make it easier to lookup tags for plugins, which is very good. But
> I don't see anything equivalent to having a tag selected from the list.
> In a typical scenario, say a plugin needs do the below (this is actually
> what I do in my tagselect.vim plugin, but I would imagine this to be the
> same for most clients of taglist() function):
>
> - Accept a tag-expression from user.
> - Get the list of all matching tags using taglist() function.
> - Show the list to user properly formatted.
> - Allow the user to select one.
> - Make vim jump to the selected tag.
>
> It is the last step that is not currently possible, and I was hoping to
> see a tagselect({expr}, tagIndex) function available.

I assume you want to select from a list of matching tags for a full
name, thus where ":tselect" results in more than one match.

> Without this
> function, there are a couple of workarounds that you can do, but they
> are not nice:
>
> - Jump to the first tag using :ta command, and use :tn with the right
>   count. The reason I don't like this is for the fact that it loads a
>   file unnecessarily, and since the tag order may not be exactly the
>   same everytime, it might continue to load a new file everytime you
>   select a different index.
> - The second workaround avoids the above problem, but it is not pretty.
>   This workaround actually came from Bram sometime back when I posed
>   this question. It involves running :ts along with the selection index
>   from a map. Something like this:
>
>     set nomore
>     nnoremap <F12> :ts {tag-expr}<CR>{tag-index}<CR>
>     exec "normal \<F12>"
>     set more
>
>   We are creating a temporary map and executing it. The problem with
>   this is that the entire list of matching tags (possibly several
>   hundred) will scroll in front of you, before the selection happens.
>   The classic way of solving such issues is to prefix the command with
>   :silent, but sadly, in this case it causes the map to fail.
>
> I am actually using the second method in my tagselect.vim plugin. I
> really like the extra convenience that I am getting from tagselect.vim
> in choosing a tag, when there are at least a few 10's of hits for the
> tag-expression, but when there are many more hits, the extra convenience
> is defeated by the lengthy scrolling that happens (which is worse if I
> am on slow connection, such as VPN). Can I request that the tagselect()
> function be added to vim7, or at least make the 2nd workaround above to
> work when used with :silent command?

There is a todo item that has been there for a while: a command like
":tag" that has arguments to specify the kind of tag and other
properties.  For example ":tag read class=MyFile" would find the read()
method in the MyFile class (if the tags file specifies that).

When the file name and the search command are added this would probably
be sufficient.  ":tag mch_mkdir file=os_unix.c"

--
TIM: But follow only if you are men of valour.  For the entrance to this cave
     is guarded by a monster, a creature so foul and cruel that no man yet has
     fought with it and lived.  Bones of full fifty men lie strewn about its
     lair ...
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\     Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html   ///
Reply | Threaded
Open this post in threaded view
|

Re: tagselec(), like taglist()

Hari Krishna Dara
In reply to this post by Hari Krishna Dara

On Fri, 22 Jul 2005 at 11:22am, Bram Moolenaar wrote:

>
> Hari Krishna Dara wrote:
>
> > I just downloaded Vim7 alpha version for W32 (thanks to Tony Mechelynck
> > for making it available) and wanted to check out the new taglist()
> > function that was added. The purpose of this function, as I can see is
> > to make it easier to lookup tags for plugins, which is very good. But
> > I don't see anything equivalent to having a tag selected from the list.
> > In a typical scenario, say a plugin needs do the below (this is actually
> > what I do in my tagselect.vim plugin, but I would imagine this to be the
> > same for most clients of taglist() function):
> >
> > - Accept a tag-expression from user.
> > - Get the list of all matching tags using taglist() function.
> > - Show the list to user properly formatted.
> > - Allow the user to select one.
> > - Make vim jump to the selected tag.
> >
> > It is the last step that is not currently possible, and I was hoping to
> > see a tagselect({expr}, tagIndex) function available.
>
> I assume you want to select from a list of matching tags for a full
> name, thus where ":tselect" results in more than one match.

Yes, your assumption is right.

>
> > Without this
> > function, there are a couple of workarounds that you can do, but they
> > are not nice:
> >
> > - Jump to the first tag using :ta command, and use :tn with the right
> >   count. The reason I don't like this is for the fact that it loads a
> >   file unnecessarily, and since the tag order may not be exactly the
> >   same everytime, it might continue to load a new file everytime you
> >   select a different index.
> > - The second workaround avoids the above problem, but it is not pretty.
> >   This workaround actually came from Bram sometime back when I posed
> >   this question. It involves running :ts along with the selection index
> >   from a map. Something like this:
> >
> >     set nomore
> >     nnoremap <F12> :ts {tag-expr}<CR>{tag-index}<CR>
> >     exec "normal \<F12>"
> >     set more
> >
> >   We are creating a temporary map and executing it. The problem with
> >   this is that the entire list of matching tags (possibly several
> >   hundred) will scroll in front of you, before the selection happens.
> >   The classic way of solving such issues is to prefix the command with
> >   :silent, but sadly, in this case it causes the map to fail.
> >
> > I am actually using the second method in my tagselect.vim plugin. I
> > really like the extra convenience that I am getting from tagselect.vim
> > in choosing a tag, when there are at least a few 10's of hits for the
> > tag-expression, but when there are many more hits, the extra convenience
> > is defeated by the lengthy scrolling that happens (which is worse if I
> > am on slow connection, such as VPN). Can I request that the tagselect()
> > function be added to vim7, or at least make the 2nd workaround above to
> > work when used with :silent command?
>
> There is a todo item that has been there for a while: a command like
> ":tag" that has arguments to specify the kind of tag and other
> properties.  For example ":tag read class=MyFile" would find the read()
> method in the MyFile class (if the tags file specifies that).
>
> When the file name and the search command are added this would probably
> be sufficient.  ":tag mch_mkdir file=os_unix.c"
>

Very close, but this might not always work. It is not uncommon to have
multiple constructors in a file, and how would you be able to
distinguish them? I assume specifying signature is not acceptable. Won't
you then need to specify an index?

--
Thanks,
Hari


               
__________________________________
Yahoo! Mail for Mobile
Take Yahoo! Mail with you! Check email on your mobile phone.
http://mobile.yahoo.com/learn/mail 
Reply | Threaded
Open this post in threaded view
|

Re: tagselec(), like taglist()

Bram Moolenaar

Hari Krishna Dara wrote:

> > There is a todo item that has been there for a while: a command like
> > ":tag" that has arguments to specify the kind of tag and other
> > properties.  For example ":tag read class=MyFile" would find the read()
> > method in the MyFile class (if the tags file specifies that).
> >
> > When the file name and the search command are added this would probably
> > be sufficient.  ":tag mch_mkdir file=os_unix.c"
> >
>
> Very close, but this might not always work. It is not uncommon to have
> multiple constructors in a file, and how would you be able to
> distinguish them? I assume specifying signature is not acceptable. Won't
> you then need to specify an index?

Well, how are they distinguished in the tags file?  If they are
identical then the tags code also doesn't know where to jump.

--
Lose weight, NEVER Diet again with
                  The "Invisible Weight Loss Patch"
                                                (spam e-mail)

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\     Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html   ///
Reply | Threaded
Open this post in threaded view
|

Re: tagselec(), like taglist()

Yegappan Lakshmanan
In reply to this post by Yegappan Lakshmanan
On 7/21/05, Yegappan Lakshmanan <[hidden email]> wrote:

> Hi Hari,
>
> On 7/21/05, Hari Krishna Dara <[hidden email]> wrote:
> >
> > I just downloaded Vim7 alpha version for W32 (thanks to Tony Mechelynck
> > for making it available) and wanted to check out the new taglist()
> > function that was added. The purpose of this function, as I can see is
> > to make it easier to lookup tags for plugins, which is very good. But
> > I don't see anything equivalent to having a tag selected from the list.
> >
>
> >
> > - Accept a tag-expression from user.
> > - Get the list of all matching tags using taglist() function.
> > - Show the list to user properly formatted.
> > - Allow the user to select one.
> > - Make vim jump to the selected tag.
> >
>
> You can use the setqflist() function to create a quickfix list with the
> matching tags returned by the taglist() function. The user can now
> browse the matching tags using the quickfix window.
>

You can use the attached script to create a quickfix list with all
the matching tags. After sourcing the script, use the
":QtagSelect <tag>" command.

- Yegappan

-----------------------------------------------------------------------------------------------------
function! QfTagSelect(tag_expr)
    if a:tag_expr == ''
        return
    endif

    let mtags = taglist(a:tag_expr)

    let tag_dict = []

    for tag_item in mtags
        " Remove the /^ and / from the tag command.
        " Add \V\^ at the beginning
        " Replace $ with \$, if present
        let start = 2
        let end = strlen(tag_item.cmd) - 1
        if tag_item.cmd[end - 1] == '$'
            let end = end - 1
        endif
        let cmd = '\V\^' . strpart(tag_item.cmd, start, end - start) .
                    \ (tag_item.cmd[end] == '$' ? '\$' : '')
        let tag_dict += [{'text': tag_item.name,
                    \ 'filename':tag_item.filename,
                    \ 'pattern':cmd}]
    endfor

    if (len(tag_dict))
        call setqflist(tag_dict)
        copen
    endif
endfunction

command! -nargs=1 QtagSelect call QfTagSelect(<q-args>)
-----------------------------------------------------------------------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: tagselec(), like taglist()

Hari Krishna Dara
In reply to this post by Hari Krishna Dara

On Fri, 22 Jul 2005 at 8:25pm, Bram Moolenaar wrote:

>
> Hari Krishna Dara wrote:
>
> > > There is a todo item that has been there for a while: a command like
> > > ":tag" that has arguments to specify the kind of tag and other
> > > properties.  For example ":tag read class=MyFile" would find the read()
> > > method in the MyFile class (if the tags file specifies that).
> > >
> > > When the file name and the search command are added this would probably
> > > be sufficient.  ":tag mch_mkdir file=os_unix.c"
> > >
> >
> > Very close, but this might not always work. It is not uncommon to have
> > multiple constructors in a file, and how would you be able to
> > distinguish them? I assume specifying signature is not acceptable. Won't
> > you then need to specify an index?
>
> Well, how are they distinguished in the tags file?  If they are
> identical then the tags code also doesn't know where to jump.
>
>

They are distinguishable by the signature of the method (type and number
of arguments). The :tagselect command shows the line as part of the
output, but that might not always be enough for the user to distinguish,
but usually it works.

--
Thanks,
Hari


               
__________________________________
Yahoo! Mail for Mobile
Take Yahoo! Mail with you! Check email on your mobile phone.
http://mobile.yahoo.com/learn/mail 
Reply | Threaded
Open this post in threaded view
|

Re: tagselec(), like taglist()

Bram Moolenaar

Hari Krishna Dara wrote:

> > > > There is a todo item that has been there for a while: a command like
> > > > ":tag" that has arguments to specify the kind of tag and other
> > > > properties.  For example ":tag read class=MyFile" would find the read()
> > > > method in the MyFile class (if the tags file specifies that).
> > > >
> > > > When the file name and the search command are added this would probably
> > > > be sufficient.  ":tag mch_mkdir file=os_unix.c"
> > >
> > > Very close, but this might not always work. It is not uncommon to have
> > > multiple constructors in a file, and how would you be able to
> > > distinguish them? I assume specifying signature is not acceptable. Won't
> > > you then need to specify an index?
> >
> > Well, how are they distinguished in the tags file?  If they are
> > identical then the tags code also doesn't know where to jump.
>
> They are distinguishable by the signature of the method (type and number
> of arguments). The :tagselect command shows the line as part of the
> output, but that might not always be enough for the user to distinguish,
> but usually it works.

We only have the info in the tags file to work with.  Usually the tag
has a search pattern.  This might help to identify functions/methods
with different arguments:

        void dosomething(int x)
        { ... }
        void dosomething(long x)
        { ... }

However, if it's written like this then the search patterns will be
identical:

        void dosomething(
                int x)
        { ... }
        void dosomething(
                long x)
        { ... }

Best we can do with the command is
        :tag dosometing cmd=/^void dosomething ($/

I'm using cmd= because in theory it could be another command then a
search command.  Could also be a line number (other commands are
rejected by Vim for security reasons).

--
BEDEVERE:  Oooooh!
LAUNCELOT: No "Aaaaarrrrrrggghhh ... " at the back of the throat.
BEDEVERE:  No!  "Oooooh!" in surprise and alarm!
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\     Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html   ///
Reply | Threaded
Open this post in threaded view
|

Re: tagselec(), like taglist()

Hari Krishna Dara
In reply to this post by Hari Krishna Dara

On Sat, 23 Jul 2005 at 1:24pm, Bram Moolenaar wrote:

>
> Hari Krishna Dara wrote:
>
> > > > > There is a todo item that has been there for a while: a command like
> > > > > ":tag" that has arguments to specify the kind of tag and other
> > > > > properties.  For example ":tag read class=MyFile" would find the
read()
> > > > > method in the MyFile class (if the tags file specifies that).
> > > > >
> > > > > When the file name and the search command are added this would
probably
> > > > > be sufficient.  ":tag mch_mkdir file=os_unix.c"
> > > >
> > > > Very close, but this might not always work. It is not uncommon to have
> > > > multiple constructors in a file, and how would you be able to
> > > > distinguish them? I assume specifying signature is not acceptable.
Won't

> > > > you then need to specify an index?
> > >
> > > Well, how are they distinguished in the tags file?  If they are
> > > identical then the tags code also doesn't know where to jump.
> >
> > They are distinguishable by the signature of the method (type and number
> > of arguments). The :tagselect command shows the line as part of the
> > output, but that might not always be enough for the user to distinguish,
> > but usually it works.
>
> We only have the info in the tags file to work with.  Usually the tag
> has a search pattern.  This might help to identify functions/methods
> with different arguments:
>
> void dosomething(int x)
> { ... }
> void dosomething(long x)
> { ... }
>
> However, if it's written like this then the search patterns will be
> identical:
>
> void dosomething(
> int x)
> { ... }
> void dosomething(
> long x)
> { ... }
>
> Best we can do with the command is
> :tag dosometing cmd=/^void dosomething ($/
>
> I'm using cmd= because in theory it could be another command then a
> search command.  Could also be a line number (other commands are
> rejected by Vim for security reasons).
>
>

I don't understand how this is going to solve the problem at hand, which
is a way to jump directly to any given tag-pattern, even if there are
several matches for the same tag/pattern. Ability to pass the tag-index
along with the tag-pattern is one way to do it, but that assumes we
already know what the index is going to be in the :tselect or taglist()
output. A non-index based approach such as the alteration to :tag above
is good, but how does it distinguish between different tags that the
given pattern (say, "do*") could match (across different files)?

--
Thank you,
Hari

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 
Reply | Threaded
Open this post in threaded view
|

Re: tagselec(), like taglist()

Bram Moolenaar

Hari Krishna Dara wrote:

> > We only have the info in the tags file to work with.  Usually the tag
> > has a search pattern.  This might help to identify functions/methods
> > with different arguments:
> >
> > void dosomething(int x)
> > { ... }
> > void dosomething(long x)
> > { ... }
> >
> > However, if it's written like this then the search patterns will be
> > identical:
> >
> > void dosomething(
> > int x)
> > { ... }
> > void dosomething(
> > long x)
> > { ... }
> >
> > Best we can do with the command is
> > :tag dosometing cmd=/^void dosomething ($/
> >
> > I'm using cmd= because in theory it could be another command then a
> > search command.  Could also be a line number (other commands are
> > rejected by Vim for security reasons).
> >
> >
>
> I don't understand how this is going to solve the problem at hand, which
> is a way to jump directly to any given tag-pattern, even if there are
> several matches for the same tag/pattern. Ability to pass the tag-index
> along with the tag-pattern is one way to do it, but that assumes we
> already know what the index is going to be in the :tselect or taglist()
> output. A non-index based approach such as the alteration to :tag above
> is good, but how does it distinguish between different tags that the
> given pattern (say, "do*") could match (across different files)?

The list of possible positions to jump to comes from tags in the tags
file.  Thus if you use the info about each tag you uniquely identify the
line in the tags file.

As you said, using the index number doesn't work, because the ordering
may change when you edit another file (static tags come first).

When there are lines in the tags file that are identical then they all
jump to the same position, there is no sense in trying to identify them.
The taglist() function returns the relevant info about the tag.  Thus if
you let the user select a tag from that list you can pass the info to a
command that will jump to the right position.

--
Every person is responsible for the choices he makes.

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\     Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html   ///
Reply | Threaded
Open this post in threaded view
|

Re: tagselec(), like taglist()

Hari Krishna Dara
In reply to this post by Hari Krishna Dara

On Mon, 25 Jul 2005 at 11:50am, Bram Moolenaar wrote:

>
> Hari Krishna Dara wrote:
>
> > > We only have the info in the tags file to work with.  Usually the tag
> > > has a search pattern.  This might help to identify functions/methods
> > > with different arguments:
> > >
> > > void dosomething(int x)
> > > { ... }
> > > void dosomething(long x)
> > > { ... }
> > >
> > > However, if it's written like this then the search patterns will be
> > > identical:
> > >
> > > void dosomething(
> > > int x)
> > > { ... }
> > > void dosomething(
> > > long x)
> > > { ... }
> > >
> > > Best we can do with the command is
> > > :tag dosometing cmd=/^void dosomething ($/
> > >
> > > I'm using cmd= because in theory it could be another command then a
> > > search command.  Could also be a line number (other commands are
> > > rejected by Vim for security reasons).
> > >
> > >
> >
> > I don't understand how this is going to solve the problem at hand, which
> > is a way to jump directly to any given tag-pattern, even if there are
> > several matches for the same tag/pattern. Ability to pass the tag-index
> > along with the tag-pattern is one way to do it, but that assumes we
> > already know what the index is going to be in the :tselect or taglist()
> > output. A non-index based approach such as the alteration to :tag above
> > is good, but how does it distinguish between different tags that the
> > given pattern (say, "do*") could match (across different files)?
>
> The list of possible positions to jump to comes from tags in the tags
> file.  Thus if you use the info about each tag you uniquely identify the
> line in the tags file.
>
> As you said, using the index number doesn't work, because the ordering
> may change when you edit another file (static tags come first).
>
> When there are lines in the tags file that are identical then they all
> jump to the same position, there is no sense in trying to identify them.
> The taglist() function returns the relevant info about the tag.  Thus if
> you let the user select a tag from that list you can pass the info to a
> command that will jump to the right position.
>

Right, that is what I thought, but sorry, I am still missing something
here. I am still not able to see how a matching pattern alone (such as
the cmd argument to :tag) distinguish between multiple files. Don't we
need to give the filename somewhere? May be an example will make it
clearer. In the help window, the pattern "/shell" would match several
help tags, something like this:

  # pri kind tag               file
  1          SHELL             c:/apps/vim/doc/starting.txt
               *SHELL*
  2 F        'noshellslash'    c:/apps/vim/doc/options.txt
               *'noshellslash'*
  .
  .

How would I now make the :tag command jump to the second one instead of
the first one? Would I pass the string in between asterisks as:

:tag /shell cmd=/'noshellslash'/

From the documentation of taglist() function, the "cmd" entry is meant
for locating the tag in a given file, so it has no meaning globally, but
in the above usage, we are not specifying a file at all, which is what
is confusing me.

--
Thanks,
Hari

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 
Reply | Threaded
Open this post in threaded view
|

Re: tagselec(), like taglist()

Bram Moolenaar

Hari Krishna Dara wrote:

> > The list of possible positions to jump to comes from tags in the tags
> > file.  Thus if you use the info about each tag you uniquely identify the
> > line in the tags file.
> >
> > As you said, using the index number doesn't work, because the ordering
> > may change when you edit another file (static tags come first).
> >
> > When there are lines in the tags file that are identical then they all
> > jump to the same position, there is no sense in trying to identify them.
> > The taglist() function returns the relevant info about the tag.  Thus if
> > you let the user select a tag from that list you can pass the info to a
> > command that will jump to the right position.
>
> Right, that is what I thought, but sorry, I am still missing something
> here. I am still not able to see how a matching pattern alone (such as
> the cmd argument to :tag) distinguish between multiple files. Don't we
> need to give the filename somewhere?

Yes, the file name can also be included.  All the info in the tags file
can be used.  Example:

        :ta mch_write cmd=/^mch_write(/ filename=os_unix.c

> May be an example will make it
> clearer. In the help window, the pattern "/shell" would match several
> help tags, something like this:
>
>   # pri kind tag               file
>   1          SHELL             c:/apps/vim/doc/starting.txt
>                *SHELL*
>   2 F        'noshellslash'    c:/apps/vim/doc/options.txt
>                *'noshellslash'*
>   .
>   .
>
> How would I now make the :tag command jump to the second one instead of
> the first one? Would I pass the string in between asterisks as:
>
> :tag /shell cmd=/'noshellslash'/

In this specific case there is only one match, thus you can use the
found tag:

  :tag 'noshellslash' cmd=/*'noshellslash'*/

Note that the pattern includes the stars, that's how it appears in the
tags file.

If there would be matches in several files add
        file=c:/apps/vim/doc/options.txt

> From the documentation of taglist() function, the "cmd" entry is meant
> for locating the tag in a given file, so it has no meaning globally, but
> in the above usage, we are not specifying a file at all, which is what
> is confusing me.

That's why you would normally include the "filename" value.

--
So when I saw the post to comp.editors, I rushed over to the FTP site to
grab it.  So I yank apart the tarball, light x candles, where x= the
vim version multiplied by the md5sum of the source divided by the MAC of
my NIC (8A3FA78155A8A1D346C3C4A), put on black robes, dim the lights,
wave a dead chicken over the hard drive, and summon the power of GNU GCC
with the magic words "make config ; make!".
                [Jason Spence, compiling Vim 5.0]

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\     Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html   ///
Reply | Threaded
Open this post in threaded view
|

Re: tagselec(), like taglist()

Hari Krishna Dara
In reply to this post by Hari Krishna Dara

On Mon, 25 Jul 2005 at 8:47pm, Bram Moolenaar wrote:

>
> Hari Krishna Dara wrote:
>
> > > The list of possible positions to jump to comes from tags in the tags
> > > file.  Thus if you use the info about each tag you uniquely identify the
> > > line in the tags file.
> > >
> > > As you said, using the index number doesn't work, because the ordering
> > > may change when you edit another file (static tags come first).
> > >
> > > When there are lines in the tags file that are identical then they all
> > > jump to the same position, there is no sense in trying to identify them.
> > > The taglist() function returns the relevant info about the tag.  Thus if
> > > you let the user select a tag from that list you can pass the info to a
> > > command that will jump to the right position.
> >
> > Right, that is what I thought, but sorry, I am still missing something
> > here. I am still not able to see how a matching pattern alone (such as
> > the cmd argument to :tag) distinguish between multiple files. Don't we
> > need to give the filename somewhere?
>
> Yes, the file name can also be included.  All the info in the tags file
> can be used.  Example:
>
> :ta mch_write cmd=/^mch_write(/ filename=os_unix.c
>
> > May be an example will make it
> > clearer. In the help window, the pattern "/shell" would match several
> > help tags, something like this:
> >
> >   # pri kind tag               file
> >   1          SHELL             c:/apps/vim/doc/starting.txt
> >                *SHELL*
> >   2 F        'noshellslash'    c:/apps/vim/doc/options.txt
> >                *'noshellslash'*
> >   .
> >   .
> >
> > How would I now make the :tag command jump to the second one instead of
> > the first one? Would I pass the string in between asterisks as:
> >
> > :tag /shell cmd=/'noshellslash'/
>
> In this specific case there is only one match, thus you can use the
> found tag:
>
>   :tag 'noshellslash' cmd=/*'noshellslash'*/
>
> Note that the pattern includes the stars, that's how it appears in the
> tags file.
>
> If there would be matches in several files add
> file=c:/apps/vim/doc/options.txt
>
> > From the documentation of taglist() function, the "cmd" entry is meant
> > for locating the tag in a given file, so it has no meaning globally, but
> > in the above usage, we are not specifying a file at all, which is what
> > is confusing me.
>
> That's why you would normally include the "filename" value.

Great, so is this feature (passing cmd and file to :tag) getting into
Vim7?

BTW, currently the :tag command recognizes spaces as part of the tag
pattern, so how are these new arguments going to be recognized?

--
Thank you,
Hari

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 
Reply | Threaded
Open this post in threaded view
|

Re: tagselec(), like taglist()

Bram Moolenaar

Hari Krishna Dara wrote:

> Great, so is this feature (passing cmd and file to :tag) getting into
> Vim7?

It's about time this gets implemented.

> BTW, currently the :tag command recognizes spaces as part of the tag
> pattern, so how are these new arguments going to be recognized?

I haven't looked into the details yet.  A tag name with a space doesn't
make much sense to me.  But if we need to support it we might need to
use another command.  ":ttag" or whatever.

--
Beer & pretzels can't be served at the same time in any bar or restaurant.
                [real standing law in North Dakota, United States of America]

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\     Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html   ///
Reply | Threaded
Open this post in threaded view
|

Re: tagselec(), like taglist()

Hari Krishna Dara
In reply to this post by Hari Krishna Dara

On Tue, 26 Jul 2005 at 11:40am, Bram Moolenaar wrote:

>
> Hari Krishna Dara wrote:
>
> > Great, so is this feature (passing cmd and file to :tag) getting into
> > Vim7?
>
> It's about time this gets implemented.

Thanks, I have been looking for this feature for a long time.

>
> > BTW, currently the :tag command recognizes spaces as part of the tag
> > pattern, so how are these new arguments going to be recognized?
>
> I haven't looked into the details yet.  A tag name with a space doesn't
> make much sense to me.  But if we need to support it we might need to
> use another command.  ":ttag" or whatever.

I agree, a tag with space might not be useful.

--
Thanks,
Hari

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 
Reply | Threaded
Open this post in threaded view
|

Re: tagselec(), like taglist()

Yegappan Lakshmanan
Hi Hari,

On 7/26/05, Hari Krishna Dara <[hidden email]> wrote:
> >
> > > Great, so is this feature (passing cmd and file to :tag) getting into
> > > Vim7?
> >
> > It's about time this gets implemented.
>
> Thanks, I have been looking for this feature for a long time.
>

You can also implement this feature/command using the taglist()
function in a script.

- Yegappan
Reply | Threaded
Open this post in threaded view
|

Re: tagselec(), like taglist()

Hari Krishna Dara
In reply to this post by Hari Krishna Dara

On Tue, 26 Jul 2005 at 10:34am, Yegappan Lakshmanan wrote:

> Hi Hari,
>
> On 7/26/05, Hari Krishna Dara <[hidden email]> wrote:
> > >
> > > > Great, so is this feature (passing cmd and file to :tag) getting into
> > > > Vim7?
> > >
> > > It's about time this gets implemented.
> >
> > Thanks, I have been looking for this feature for a long time.
> >
>
> You can also implement this feature/command using the taglist()
> function in a script.
>
> - Yegappan

Are you saying taglist() already includes what I have been asking for,
and what Bram described earlier as a possible solution through
enhancements to :tag command? How can this be done? Can you please give
an example?

--
Thanks,
Hari

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 
Reply | Threaded
Open this post in threaded view
|

Re: tagselec(), like taglist()

Yegappan Lakshmanan
Hi Hari,

On 7/26/05, Hari Krishna Dara <[hidden email]> wrote:

> >
> > You can also implement this feature/command using the taglist()
> > function in a script.
> >
> > - Yegappan
>
> Are you saying taglist() already includes what I have been asking for,
> and what Bram described earlier as a possible solution through
> enhancements to :tag command? How can this be done? Can you please give
> an example?
>

I was thinking of using the following function to implement a command
to jump to a tag based on the specified criteria. But this command doesn't
work properly with the tag stack.

So we do need to extend the ":tag" command to accept the additional
criteria.

- Yegappan

-------------------------------------------------------------------------------------------------------
function! s:tag_ext (select, tagname)
    let tagmatches = taglist(a:tagname)
    if tagmatches == []
        echo 'Tag ' . a:tagname . ' not found'
        return
    endif

    let [select_type, value] = split(a:select, '=')

    let idx = -1

    " Select a item based on the specified criteria
    for item in tagmatches
        let idx = idx + 1
        if !has_key(item, select_type)
            continue
        endif

        if item[select_type] =~ value
            exe 'tag ' . a:tagname
            exe idx . 'tnext'
        endif
    endfor

    echo 'Tag matching ' . a:select . ' not found'
endfunction

command! -nargs=+ -complete=tag Tag call s:tag_ext(<f-args>)