Commits

Takeshi NISHIDA committed ad3a23d

changed aroundmrufile behaviour

Comments (0)

Files changed (6)

autoload/fuf/aroundmrufile.vim

 endfunction
 
 "
+function s:expandSearchDir(dir, level)
+  let dirs = [a:dir]
+  let dirPrev = a:dir
+  for i in range(a:level)
+    let dirPrev = l9#concatPaths([dirPrev, '*'])
+    call add(dirs, dirPrev)
+  endfor
+  let dirPrev = a:dir
+  for i in range(a:level)
+    let dirPrevPrev = dirPrev
+    let dirPrev = fnamemodify(dirPrev, ':h')
+    if dirPrevPrev ==# dirPrev
+      break
+    endif
+    call add(dirs, dirPrev)
+  endfor
+  return dirs
+endfunction
+
+"
 function s:listFilesUsingCache(dir)
   if !exists('s:cache[a:dir]')
     let s:cache[a:dir] = [a:dir] +
           \              split(glob(a:dir . l9#getPathSeparator() . "*" ), "\n") +
           \              split(glob(a:dir . l9#getPathSeparator() . ".*"), "\n")
-    call filter(s:cache[a:dir], 'v:val !~ ''\v(^|[/\\])\.\.?$''')
-    call map(s:cache[a:dir], 'fuf#makePathItem(fnamemodify(v:val, ":~"), "", 1)')
+    call filter(s:cache[a:dir], 'filereadable(v:val)')
+    call map(s:cache[a:dir], 'fuf#makePathItem(fnamemodify(v:val, ":~"), "", 0)')
     if len(g:fuf_aroundmrufile_exclude)
       call filter(s:cache[a:dir], 'v:val.word !~ g:fuf_aroundmrufile_exclude')
     endif
 " s:handler {{{1
 
 let s:handler = {}
+let s:OPEN_TYPE_EXPAND = -1
 
 "
 function s:handler.getModeName()
 
 "
 function s:handler.getPrompt()
-  return fuf#formatPrompt(g:fuf_aroundmrufile_prompt, self.partialMatching, '')
+  let levelString = '[' . g:fuf_aroundmrufile_searchLevel . ']'
+  return fuf#formatPrompt(g:fuf_aroundmrufile_prompt, self.partialMatching, levelString)
 endfunction
 
 "
 
 "
 function s:handler.onOpen(word, mode)
-  if isdirectory(expand(a:word))
-    let self.reservedMode = 'file'
-    let self.lastPattern = a:word
+  if a:mode ==# s:OPEN_TYPE_EXPAND
+    call fuf#setOneTimeVariables(['g:fuf_aroundmrufile_searchLevel',
+          \                       self.searchLevel + 1])
+    let self.reservedMode = self.getModeName()
+    return
   else
     call fuf#openFile(a:word, a:mode, g:fuf_reuseWindow)
   endif
 
 "
 function s:handler.onModeEnterPost()
+  let self.searchLevel = g:fuf_aroundmrufile_searchLevel
+  call fuf#defineKeyMappingInHandler(g:fuf_aroundmrufile_keyExpand,
+        \                            'onCr(' . s:OPEN_TYPE_EXPAND . ')')
   " NOTE: Comparing filenames is faster than bufnr('^' . fname . '$')
   let bufNamePrev = fnamemodify(bufname(self.bufNrPrev), ':p:~')
   let self.items = fuf#loadDataFile(s:MODE_NAME, 'items')
-  call map(self.items, 's:listFilesUsingCache(v:val.word)')
+  call map(self.items, 's:expandSearchDir(v:val.word, g:fuf_aroundmrufile_searchLevel)')
+  let self.items = l9#concat(self.items)
+  let self.items = l9#unique(self.items)
+  call map(self.items, 's:listFilesUsingCache(v:val)')
   let self.items = l9#concat(self.items)
   call filter(self.items, '!empty(v:val) && v:val.word !=# bufNamePrev')
   call fuf#mapToSetSerialIndex(self.items, 1)

autoload/fuf/bookmark.vim

 "
 function s:handler.onModeEnterPost()
   call fuf#defineKeyMappingInHandler(g:fuf_bookmark_keyDelete,
-        \                            'onCr(' . s:OPEN_TYPE_DELETE . ', 0)')
+        \                            'onCr(' . s:OPEN_TYPE_DELETE . ')')
   let self.items = fuf#loadDataFile(s:MODE_NAME, 'items')
   call map(self.items, 'fuf#makeNonPathItem(v:val.word, strftime(g:fuf_timeFormat, v:val.time))')
   call fuf#mapToSetSerialIndex(self.items, 1)

autoload/fuf/buffer.vim

 "
 function s:handler.onModeEnterPost()
   call fuf#defineKeyMappingInHandler(g:fuf_buffer_keyDelete,
-        \                            'onCr(' . s:OPEN_TYPE_DELETE . ', 0)')
+        \                            'onCr(' . s:OPEN_TYPE_DELETE . ')')
   let self.items = range(1, bufnr('$'))
   call filter(self.items, 'buflisted(v:val) && v:val != self.bufNrPrev && v:val != bufnr("%")')
   call map(self.items, 's:makeItem(v:val)')
 Around-MRU-File モード ~
 
 このモードは最近使ったファイルの付近にあるファイルを選択して開くインターフェー
-スを提供します。ディレクトリを選択した場合、そこからFile モードを開始します。
+スを提供します。
+
+Around-MRU-File モード中に <C-]> (|g:fuf_aroundmrufile_keyExpand|) を押すと、
+ディレクトリツリーの検索範囲を広げます。(|g:fuf_aroundmrufile_searchLevel|)
 
 |BufEnter| と |BufWritePost| で行う処理がパフォーマンス上の問題を起こしうるの
 で、デフォルトでは|g:fuf_modesDisable|で無効化するモードに指定されています。
 <
         保持するMRUアイテムの親ディレクトリの上限値。
 
+                                          *g:fuf_aroundmrufile_searchLevel*  >
+  let g:fuf_aroundmrufile_searchLevel = 0
+<
+        検索するディレクトリツリーの上下の階層数。
+
+
+                                            *g:fuf_aroundmrufile_keyExpand*  >
+  let g:fuf_aroundmrufile_keyExpand = '<C-]>'
+<
+        |g:fuf_aroundmrufile_searchLevel|を1増やすキー。
+
                                                  *fuf-options-for-mrucmd-mode*
 MRU-Cmd モード用 ~
 
   nnoremap <silent> <C-p>      :FufFileWithCurrentBufferDir<CR>
   nnoremap <silent> <C-f><C-p> :FufFileWithFullCwd<CR>
   nnoremap <silent> <C-f>p     :FufFile<CR>
+  nnoremap <silent> <C-f><C-a> :FufAllFileChangeCoverage<CR>
+  nnoremap <silent> <C-f>a     :FufAllFileRegisterCoverage<CR>
   nnoremap <silent> <C-f><C-d> :FufDirWithCurrentBufferDir<CR>
   nnoremap <silent> <C-f>d     :FufDirWithFullCwd<CR>
   nnoremap <silent> <C-f>D     :FufDir<CR>
 This mode provides an interface to select a buffer from a list of existing
 buffers and open it.
 
-Press <C-]> (|g:fuf_buffer_keyDelete|) in Buffer mode and selected buffer will
+Press <C-]> (|g:fuf_buffer_keyDelete|) in this mode and selected buffer will
 be deleted.
 
                                                                *fuf-file-mode*
 Around-MRU-File mode ~
 
 This mode provides an interface to select a file around the most recently used
-files and open it. If a directory is selected, File mode will be launched from
-there.
+files and open it.
+
+Press <C-]> (|g:fuf_aroundmrufile_keyExpand|) in this mode and search range of
+the directory tree are expanded. (|g:fuf_aroundmrufile_searchLevel|)
 
 This mode is set to disable in |g:fuf_modesDisable| by default because
 processes for this mode in |BufEnter| and |BufWritePost| could cause
 bookmarked line number without the adjustment, set
 |g:fuf_bookmark_searchRange| option to 0.
 
-Press <C-]> (|g:fuf_bookmark_keyDelete|) in Bookmark mode and selected
-bookmark will be deleted.
+Press <C-]> (|g:fuf_bookmark_keyDelete|) in this mode and selected bookmark
+will be deleted.
 
                                                                 *fuf-tag-mode*
 Tag mode ~
         Ceiling for the number of parent directories of MRU items to be
         stored.
 
+                                          *g:fuf_aroundmrufile_searchLevel*  >
+  let g:fuf_aroundmrufile_searchLevel = 0
+<
+        Level number of the directory tree to search upward/downward.
+
+                                            *g:fuf_aroundmrufile_keyExpand*  >
+  let g:fuf_aroundmrufile_keyExpand = '<C-]>'
+<
+        Key mapped to increase |g:fuf_aroundmrufile_searchLevel| by 1.
+
                                                  *fuf-options-for-mrucmd-mode*
 For MRU-Cmd Mode ~
 
   nnoremap <silent> <C-p>      :FufFileWithCurrentBufferDir<CR>
   nnoremap <silent> <C-f><C-p> :FufFileWithFullCwd<CR>
   nnoremap <silent> <C-f>p     :FufFile<CR>
+  nnoremap <silent> <C-f><C-a> :FufAllFileChangeCoverage<CR>
+  nnoremap <silent> <C-f>a     :FufAllFileRegisterCoverage<CR>
   nnoremap <silent> <C-f><C-d> :FufDirWithCurrentBufferDir<CR>
   nnoremap <silent> <C-f>d     :FufDirWithFullCwd<CR>
   nnoremap <silent> <C-f>D     :FufDir<CR>
   - Added :FufEditDataFile command and removed :FufEditInfo command.
   - Added g:fuf_fuzzyRefining option.
   - Changed the default value of g:fuf_previewHeight to 0 in order to disable
+  - Changed the default value of g:fuf_modesDisable option.
+  - Changed the default value of g:fuf_*_switchOrder options.
   - Improved speed of changing buffers.
   - Improved the way to add modes.
     preview feature. There is an unfixable problem which is caused by a Vim's
   call l9#defineVariableDefault('g:fuf_aroundmrufile_prompt'     , '>Around-MRU-File[]>')
   call l9#defineVariableDefault('g:fuf_aroundmrufile_switchOrder', 60)
   call l9#defineVariableDefault('g:fuf_aroundmrufile_exclude'    , '\v\~$|\.(o|exe|dll|bak|orig|sw[po])$|(^|[/\\])\.(hg|git|bzr)($|[/\\])|^(\/\/|\\\\|\/mnt\/|\/media\/)')
-  call l9#defineVariableDefault('g:fuf_aroundmrufile_maxDir'    , 100)
+  call l9#defineVariableDefault('g:fuf_aroundmrufile_maxDir'     , 100)
+  call l9#defineVariableDefault('g:fuf_aroundmrufile_searchLevel', 0)
+  call l9#defineVariableDefault('g:fuf_aroundmrufile_keyExpand'  , '<C-]>')
   "---------------------------------------------------------------------------
   call l9#defineVariableDefault('g:fuf_mrucmd_prompt'     , '>MRU-Cmd[]>')
   call l9#defineVariableDefault('g:fuf_mrucmd_switchOrder', 70)