On Wed, Sep 7, 2011 at 9:01 PM, Benjamin Fritz <[email protected]> wrote:
>
>> Seemingly also, Vim doesn't like this line:
>>
>> let g:last_tag_file = []
>>
>> It seems to take exception to "[]" -- changing it to the empty string
>> "", seems to work, but again, I'm clutching at straws knowing nothing
>> about Vimscript.
>>
>
> This line should be fine, it assigns an empty List to g:last_tag_file.
> I don't know how that could fail.
>
There was an extraneous ';' character on the line somehow.
Here's what I ended up with, but now I'm stuck:
nnoremap <C-]> :call <SID>SmartTagSearch()<CR>
let g:last_tag_file = []
function! s:SmartTagSearch()
" get the first tag hit for the word under the cursor
let searchstr = expand("<cword>")
let foundtags = taglist(searchstr)
if empty(foundtags)
echohl Error
echomsg "Tag" searchstr "not found!"
echohl None
endif
let firsttag = foundtags[0]
" save off the current file in case we need it again
call add(g:last_tag_file, expand("%:p"))
" jump to the file containing the tag (in existing window if possible)
execute 'drop' fnameescape(firsttag.filename)
" jump to the tag itself
execute 'tag' searchstr
endfunction
nnoremap <C-T> :call <SID>SmartTagReturn()<CR>
function! s:SmartTagReturn()
if (empty(g:last_tag_file))
echohl Error
echomsg "Tag file stack empty"
echohl None
return
endif
" jump to the file containing the pre-tag position (in existing
window if possible)
execute 'drop' remove(g:last_tag_file, -1)
" jump to the pre-tag position itself
pop
endfunction
When I use this version, jumping to a tag with CTRL-] works fine. But,
jumping back with CTRL-T or with :pop does nothing. Repeating the
operation gives a "tag stack empty" message. What's going on here?
--
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