taglist+minibufexpl

这两个plugin在 www.vim.org 是排名前两位的(by rating),但是所谓鱼与熊掌不可兼得,minibufexpl与taglist合用时还是存在一点小问题。

在切换buffer时,如果之前焦点定位于taglist的窗口中,minibufexpl会毫不客气地在taglist的窗口中载入文件。为了解决这一点瑕疵,我对minibufexpl做了一点小修正。

请用以下代码替换原函数MBESelectBuffer()

 

"  MBENeedNextWindow - From the MBE window, test window under the cursor {{{
"
 
"
 If we are in our explorer, then we attempt to open the buffer under the
"
 cursor in the previous window.
"
function !   < SID > MBENeedNextWindow()
  
if  bufname( ' % ' ==   ' -MiniBufExplorer- '   ||
     bufname(
' % ' ==   ' __Tag_List__ '   ||
     (g:miniBufExplModSelTarget 
==   1   &&  getbufvar(bufnr( ' % ' ),  ' &modifiable ' ==   0 )
    
return   1
  
else
    
return   0
  endif
endfunction

"  }}}
"
 MBESelectBuffer - From the MBE window, open buffer under the cursor {{{
"
 
"
 If we are in our explorer, then we attempt to open the buffer under the
"
 cursor in the previous window.
"
function !   < SID > MBESelectBuffer()
  call 
< SID > DEBUG( ' =========================== ' , 10 )
  call 
< SID > DEBUG( ' Entering MBESelectBuffer() '  , 10 )
  call 
< SID > DEBUG( ' =========================== ' , 10 )

  
"  Make sure we are in our window
   if  bufname( ' % ' !=   ' -MiniBufExplorer- '
    call 
< SID > DEBUG( ' MBESelectBuffer called in invalid window ' , 1 )
    
return  
  endif

  let l:save_rep 
=   & report
  let l:save_sc  
=   & showcmd
  let 
& report     =   10000
  
set  noshowcmd 
  
  let l:bufnr  
=   < SID > GetSelectedBuffer()
  let l:resize 
=   0

  
if (l:bufnr  !=   - 1 )              "  If the buffer exists.

    let l:saveAutoUpdate 
=  g:miniBufExplorerAutoUpdate
    let g:miniBufExplorerAutoUpdate 
=   0
    
"  Switch to the previous window
    wincmd p
    
    let curbufname 
=  bufname( ' % ' )
    
"  If we are in the buffer explorer or in a nonmodifiable buffer with
     "  g:miniBufExplModSelTarget set then try another window (a few times)

    
while   < SID > MBENeedNextWindow()
        wincmd w
        
if  bufname( ' % ' ==  curbufname
            
break
        endif
    endwhile
    
"  The following handles the case where -MiniBufExplorer-
     "  is the only window left. We need to resize so we don't
     "  end up with a 1 or two line buffer. 
     if  bufname( ' % ' ==   ' -MiniBufExplorer- '
        let l:resize 
=   1
    endif

    exec(
' b!  ' .l:bufnr)
    
if  (l:resize)
      resize
    endif
    let g:miniBufExplorerAutoUpdate 
=  l:saveAutoUpdate
    call 
< SID > AutoUpdate( - 1 )

  endif

  let 
& report   =  l:save_rep
  let 
& showcmd  =  l:save_sc

  call 
< SID > DEBUG( ' =========================== ' , 10 )
  call 
< SID > DEBUG( ' Completed MBESelectBuffer() ' , 10 )
  call 
< SID > DEBUG( ' =========================== ' , 10 )

endfunction
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值