move a couple of functions into NERDTreeCreator

The "next buffer name" functions are only used in NERDTreeCreator so put
them there.
This commit is contained in:
Martin Grenfell
2013-01-09 09:48:16 +00:00
parent c3b63d2fd9
commit 64cb6204cc
3 changed files with 28 additions and 28 deletions

View File

@@ -33,11 +33,6 @@ function! nerdtree#bufInWindows(bnum)
return cnt
endfunction
" FUNCTION: nerdtree#bufNamePrefix() {{{2
function! nerdtree#bufNamePrefix()
return 'NERD_tree_'
endfunction
"FUNCTION: nerdtree#checkForBrowse(dir) {{{2
"inits a secondary nerd tree in the current buffer if appropriate
function! nerdtree#checkForBrowse(dir)
@@ -232,25 +227,6 @@ function! nerdtree#invokeKeyMap(key)
call g:NERDTreeKeyMap.Invoke(a:key)
endfunction
" FUNCTION: nerdtree#nextBufferName() {{{2
" returns the buffer name for the next nerd tree
function! nerdtree#nextBufferName()
let name = nerdtree#bufNamePrefix() . nerdtree#nextBufferNumber()
return name
endfunction
" FUNCTION: nerdtree#nextBufferNumber() {{{2
" the number to add to the nerd tree buffer name to make the buf name unique
function! nerdtree#nextBufferNumber()
if !exists("s:nextBufNum")
let s:nextBufNum = 1
else
let s:nextBufNum += 1
endif
return s:nextBufNum
endfunction
" FUNCTION: nerdtree#postSourceActions() {{{2
function! nerdtree#postSourceActions()
call g:NERDTreeBookmark.CacheBookmarks(0)

View File

@@ -161,10 +161,10 @@ command! -n=0 -bar NERDTreeCWD call NERDTreeCWD()
"============================================================
augroup NERDTree
"Save the cursor position whenever we close the nerd tree
exec "autocmd BufWinLeave ". nerdtree#bufNamePrefix() ."* call nerdtree#saveScreenState()"
exec "autocmd BufWinLeave ". g:NERDTreeCreator.BufNamePrefix() ."* call nerdtree#saveScreenState()"
"disallow insert mode in the NERDTree
exec "autocmd BufEnter ". nerdtree#bufNamePrefix() ."* stopinsert"
exec "autocmd BufEnter ". g:NERDTreeCreator.BufNamePrefix() ."* stopinsert"
augroup END
if g:NERDTreeHijackNetrw

View File

@@ -27,6 +27,11 @@ function! s:Creator._broadcastInitEvent()
silent doautocmd User NERDTreeInit
endfunction
" FUNCTION: s:Creator.BufNamePrefix() {{{2
function! s:Creator.BufNamePrefix()
return 'NERD_tree_'
endfunction
"FUNCTION: s:Creator.CreatePrimary(a:name) {{{1
function! s:Creator.CreatePrimary(name)
let creator = s:Creator.New()
@@ -91,7 +96,7 @@ function! s:Creator.createSecondary(dir)
"we need a unique name for each secondary tree buffer to ensure they are
"all independent
exec "silent edit " . nerdtree#nextBufferName()
exec "silent edit " . self._nextBufferName()
let b:NERDTreePreviousBuf = bufnr(previousBuf)
@@ -174,7 +179,7 @@ function! s:Creator._createTreeWin()
let splitSize = g:NERDTreeWinSize
if !exists('t:NERDTreeBufName')
let t:NERDTreeBufName = nerdtree#nextBufferName()
let t:NERDTreeBufName = self._nextBufferName()
silent! exec splitLocation . 'vertical ' . splitSize . ' new'
silent! exec "edit " . t:NERDTreeBufName
else
@@ -192,6 +197,25 @@ function! s:Creator.New()
return newCreator
endfunction
" FUNCTION: s:Creator._nextBufferName() {{{2
" returns the buffer name for the next nerd tree
function! s:Creator._nextBufferName()
let name = s:Creator.BufNamePrefix() . self._nextBufferNumber()
return name
endfunction
" FUNCTION: s:Creator._nextBufferNumber() {{{2
" the number to add to the nerd tree buffer name to make the buf name unique
function! s:Creator._nextBufferNumber()
if !exists("s:Creator._NextBufNum")
let s:Creator._NextBufNum = 1
else
let s:Creator._NextBufNum += 1
endif
return s:Creator._NextBufNum
endfunction
"FUNCTION: s:Creator._pathForString(str) {{{1
"find a bookmark or adirectory for the given string
function! s:Creator._pathForString(str)