Skip to content

Commit 0651895

Browse files
committed
commit version 1.91 (released on Nov 5, 2002)
1 parent 150014f commit 0651895

File tree

1 file changed

+62
-19
lines changed

1 file changed

+62
-19
lines changed

plugin/taglist.vim

Lines changed: 62 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
" File: taglist.vim
22
" Author: Yegappan Lakshmanan
3-
" Version: l.9
4-
" Last Modified: Oct 07, 2002
3+
" Version: l.91
4+
" Last Modified: Nov 5, 2002
55
"
66
" Overview
77
" --------
@@ -276,7 +276,7 @@ let s:tlist_fortran_tag_types = 'block_data common entry function interface type
276276

277277
" java language
278278
let s:tlist_java_ctags_args = '--language-force=java --java-types=pcifm'
279-
let s:tlist_java_tag_types = 'interface package class method field'
279+
let s:tlist_java_tag_types = 'package class interface field method'
280280

281281
" lisp language
282282
let s:tlist_lisp_ctags_args = '--language-force=lisp --lisp-types=f'
@@ -401,6 +401,35 @@ function! s:Tlist_Warning_Msg(msg)
401401
echohl None
402402
endfunction
403403

404+
" Tlist_Skip_Buffer()
405+
" Check whether tag listing is supported for the specified buffer.
406+
function! s:Tlist_Skip_Buffer(bufnum)
407+
" Skip buffers with 'buftype' set to nofile, nowrite, quickfix or help
408+
if getbufvar(a:bufnum, '&buftype') != ''
409+
return 1
410+
endif
411+
412+
" Skip buffers with filetype not set
413+
if getbufvar(a:bufnum, '&filetype') == ''
414+
return 1
415+
endif
416+
417+
let filename = fnamemodify(bufname(a:bufnum), '%:p')
418+
419+
" Skip buffers with no names
420+
if filename == ''
421+
return 1
422+
endif
423+
424+
" Skip files which are not readable or files which are not yet stored
425+
" to the disk
426+
if !filereadable(filename)
427+
return 1
428+
endif
429+
430+
return 0
431+
endfunction
432+
404433
" Tlist_Toggle_Window()
405434
" Open or close a taglist window
406435
function! s:Tlist_Toggle_Window(bufnum)
@@ -412,16 +441,21 @@ function! s:Tlist_Toggle_Window(bufnum)
412441
" If taglist window is open then close it.
413442
let winnum = bufwinnr(bname)
414443
if winnum != -1
415-
" Goto the taglist window, close it and then come back to the original
416-
" window
417-
let curbufnr = bufnr('%')
418-
exe winnum . 'wincmd w'
419-
close
420-
" Need to jump back to the original window only if we are not already
421-
" in that window
422-
let winnum = bufwinnr(curbufnr)
423-
if winnr() != winnum
444+
if winnr() == winnum
445+
" Already in the taglist window. Close it and return
446+
close
447+
else
448+
" Goto the taglist window, close it and then come back to the
449+
" original window
450+
let curbufnr = bufnr('%')
424451
exe winnum . 'wincmd w'
452+
close
453+
" Need to jump back to the original window only if we are not
454+
" already in that window
455+
let winnum = bufwinnr(curbufnr)
456+
if winnr() != winnum
457+
exe winnum . 'wincmd w'
458+
endif
425459
endif
426460
return
427461
endif
@@ -630,8 +664,16 @@ function! s:Tlist_Explore_File(bufnum)
630664
let ctags_args = ctags_args . ' ' . s:tlist_{ftype}_ctags_args
631665

632666
" Ctags command to produce output with regexp for locating the tags
633-
let ctags_cmd = g:Tlist_Ctags_Cmd . ctags_args
634-
let ctags_cmd = ctags_cmd . ' "' . filename . '"'
667+
if (has('win32') && !has('win95'))
668+
" When using cmd.exe in MS-Windows, extra quotes must be added at
669+
" the beginning and at the end of the command line. These will
670+
" be removed by cmd.exe. Refer to cmd /? for more information
671+
let ctags_cmd = '""' . g:Tlist_Ctags_Cmd . '"' . ctags_args
672+
let ctags_cmd = ctags_cmd . ' "' . filename . '""'
673+
else
674+
let ctags_cmd = '"' . g:Tlist_Ctags_Cmd . '"' . ctags_args
675+
let ctags_cmd = ctags_cmd . ' "' . filename . '"'
676+
endif
635677

636678
" Run ctags and get the tag list
637679
let cmd_output = system(ctags_cmd)
@@ -844,14 +886,15 @@ function! s:Tlist_Refresh_Window()
844886
return
845887
endif
846888

847-
let filename = expand('%:p')
848-
let curline = line('.')
849-
850-
" No need to refresh taglist window
851-
if filename =~? '__Tag_List__'
889+
" If the buffer doesn't support tag listing, skip it
890+
if s:Tlist_Skip_Buffer(bufnr('%'))
852891
return
853892
endif
854893

894+
let filename = expand('%:p')
895+
896+
let curline = line('.')
897+
855898
" Tag list window name
856899
let bname = '__Tag_List__'
857900

0 commit comments

Comments
 (0)