On Sep 5, 4:37 pm, Jacky Liu <[email protected]> wrote:
> On Sep 6, 3:35 am, David Chanters <[email protected]>
> wrote:
>
>         nnoremap! <Ctrl-]> :call <SID>SmartTagSearch()<CR>
>
>         function! s:SmartTagSearch()
>                 if {file opened in current tab}
>                         " switch to that window
>                         " locate the tag
>                 else
>                         normal! <C-]>
>                 endif
>         endfunction
>
> Brief steps implementing s:SmartTagSearch() :
>
> 1. expand() to get the word under the cursor(tag name)
>
> 2. taglist() to get the target file name of the tag
>
> 3. tabpagebuflist() + bufname() to see if that file is opened in the
> current tab, if so the window number is determined
>

I'd rather just use the :drop command, which will jump to another
window if that other window already contains the file in question, re-
use the current window, or split a new window if the current buffer
cannot be abandoned.

> 4. :exe + :normal ^W^W to switch to that window
>
> 5. use the {cmd} got in 1. to locate the tag
>

That would be in 2. But I'm not sure of the format. Is this something
you can just use :execute on?

> Taking all tab pages into account is no problem either, just introduce
> tabpagenr() and :gt
>

Even better, :tab drop

> <Ctrl-t> is just the other way round.
>

I think CTRL-T would be very different actually, unless I'm missing
something. You could accomplish it by storing the current buffer
number, and using the :sbuffer command and the 'switchbuf' option, but
more likely if the CTRL-] is implemented as desired you can just
switch back to the previous window and be where you want to be.

> This should work, theoretically. But I haven't tried it.
>

Here's a more complete script, but I haven't tested it either:

         nnoremap! <Ctrl-]> :call <SID>SmartTagSearch()<CR>

         function! s:SmartTagSearch()
             " get the first tag hit for the word under the cursor
             let firsttag = taglist(expand("<cword>"))[0]
             " jump to the file containing the tag (in existing window
if possible)
             execute 'drop' fnameescape(firsttag.filename)
             " jump to the tag itself
             execute firsttag.cmd
         endfunction

> Plus: what does the "CC" mean?

There have been a few answers, I'm not sure if one of them is correct.
I actually read somewhere that CC meant "courtesy copy". BCC is
related, meaning "blind courtesy copy". But apparently the actual
definitions have long been lost since there are so many ideas for it
now, even if the meanings are clear.

-- 
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 via email to