Quantcast

How to show custom taglist in window like :tag or :ptag

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

How to show custom taglist in window like :tag or :ptag

stevenfrog-2
I use taglist() to get a tag list. Then I did some filter, just leave
some useful one like this:

let tttlist = taglist("^List$")
let newtttlist = []
for item in tttlist
   if item['kind'] == 'i' || item['kind'] == 'c'
       call add(newtttlist, item)
   endif
endfor
echo newtttlist

But how to show them like :tag and :ptag in vim?

--
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: How to show custom taglist in window like :tag or :ptag

Ben Fritz
On Tuesday, May 29, 2012 9:38:16 PM UTC-5, stevenfrog wrote:

> I use taglist() to get a tag list. Then I did some filter, just leave
> some useful one like this:
>
> let tttlist = taglist("^List$")
> let newtttlist = []
> for item in tttlist
>    if item['kind'] == 'i' || item['kind'] == 'c'
>        call add(newtttlist, item)
>    endif
> endfor
> echo newtttlist
>
> But how to show them like :tag and :ptag in vim?

I don't understand what you're trying to achieve.

Assuming your taglist contains tags named "List" your code will echo them to the screen. Which tag do you wish to jump to? If you have the tag name in a variable, like tag_i_want_to_jump_to, you can jump to it with something like:

  :exec "tag" tag_i_want_to_jump_to

If you want to do something else, please try to tell us SPECIFICALLY what you are trying to do, what you tried, what you expected to happen, and what happened instead.

--
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: How to show custom taglist in window like :tag or :ptag

stevenfrog-2
In reply to this post by stevenfrog-2
    Ben Fritz [hidden email] May 31 11:01AM -0700  

    On Tuesday, May 29, 2012 9:38:16 PM UTC-5, stevenfrog wrote:
    > endfor
    > echo newtttlist
     
    > But how to show them like :tag and :ptag in vim?
     
    I don't understand what you're trying to achieve.
     
    Assuming your taglist contains tags named "List" your code will echo them to the screen. Which tag do you wish to jump to? If you have the tag name in a variable, like tag_i_want_to_jump_to, you can jump to it with something like:
     
    :exec "tag" tag_i_want_to_jump_to
     
    If you want to do something else, please try to tell us SPECIFICALLY what you are trying to do, what you tried, what you expected to happen, and what happened instead.

     


Please ignore the "echo newtttlist
I just use it for testing.
This function's is used filter the tags.
I search tags with name "List", and only left 'c, i'.
For example:
There are 10 tags, after my function filter, there are only 3 left.
Then I want to now how to show then like :tag,
The original ':tag XXX' show tags in a seperate window and ask user to select one and jump to it.
If I filter some of them, it make easier to select one tag from list.
 

--
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: How to show custom taglist in window like :tag or :ptag

Ben Fritz
> Please ignore the "echo newtttlist
> I just use it for testing.
> This function's is used filter the tags.
> I search tags with name "List", and only left 'c, i'.
> For example:
> There are 10 tags, after my function filter, there are only 3 left.

I understand so far.

> Then I want to now how to show then like :tag,

Now you've lost me again. :tag is for jumping to tags, not showing them.

> The original ':tag XXX' show tags in a seperate window and ask user to select one and jump to it.

That's not at all what :tag does. Here's the help text:

:[count]ta[g][!] {ident}
                        Jump to the definition of {ident}, using the
                        information in the tags file(s).  Put {ident} in the
                        tag stack.  See |tag-!| for [!].
                        {ident} can be a regexp pattern, see |tag-regexp|.
                        When there are several matching tags for {ident}, jump
                        to the [count] one.  When [count] is omitted the
                        first one is jumped to. See |tag-matchlist| for
                        jumping to other matching tags.

Even :tselect, which DOES show a list, only prints the list to the screen and
prompts you for input, it does NOT show the list in a separate window.

I suspect you want behavior like :tselect. If :tag does the same thing for you
as :tselect, then you probably have the 'cscopetag' option set, so that :tag and
CTRL-] act like :tjump, which in turn acts like :tselect if there are multiple
matches. But I'm just guessing here.

If you do want behavior like :tselect, you can loop over your filtered tag list
and use an "echo" command to show whatever you want to the user. Then you can
use the input() function to allow the user to select an entry.

If you actually want to open a scratch buffer, you can do that too. There are
many ways to get text into the buffer, you'll just need to figure out how to
allow the user to select a tag from the buffer. Probably you'll want to set
buftype=nofile and apply a buffer-local mapping or something.

--
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
Loading...