Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Version 0.7

- NEW: g:tselectfiles_part_subst* variables (for use with tselectfiles#BaseFilter())
- NEW: [bg]:tselectfiles_filter_basename variable (if true, match on basename only)
  • Loading branch information...
commit 744b5b243f855d0a921db4fc719356b8696a0e22 1 parent c7828f4
@tomtom tomtom authored committed
View
24 autoload/tselectfiles.vim
@@ -3,8 +3,8 @@
" @Website: http://www.vim.org/account/profile.php?user_id=4037
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2007-10-15.
-" @Last Change: 2008-10-03.
-" @Revision: 0.0.179
+" @Last Change: 2008-10-16.
+" @Revision: 0.0.197
if &cp || exists("loaded_tselectfiles_autoload")
finish
@@ -350,7 +350,7 @@ function! tselectfiles#FormatVikiMetaDataOrFirstLine(filename) "{{{3
let acc = []
let cont = 0
for l in lines
- if cont || l =~ '^\(\*\|\s*#\(TI\|AU\|DATE\|VAR\)\)' || empty(acc)
+ if cont || l =~ '^\(\*\|\s*#\(TI\(TLE\)\?\|AU\(THOR\)\?\|DATE\|VAR\)\>\)' || empty(acc)
let cont = 0
if l =~ '\\$'
let l = substitute(l, '\\\s*$', '', '')
@@ -391,6 +391,16 @@ function! tselectfiles#FormatEntry(world, filename) "{{{3
endf
+function! tselectfiles#FormatFilter(world, filename) "{{{3
+ let mode = tlib#var#Get('tselectfiles_filter_basename', 'bg', 0)
+ if mode
+ return fnamemodify(a:filename, ':t')
+ else
+ return a:filename
+ endif
+endf
+
+
function! tselectfiles#SelectFiles(mode, dir)
" TLogVAR a:mode, a:dir
let s:select_files_buffer = bufnr('%')
@@ -451,7 +461,13 @@ function! tselectfiles#BaseFilter(...) "{{{3
let rplc = a:0 >= 2 ? a:2 : ''
let file = substitute(file, a:1, rplc, 'g')
endif
- let b:tselectfiles_filter_rx = join(split(file, '\A'), '\|')
+ let parts = split(file, '\A')
+ let subst = tlib#var#Get('tselectfiles_part_subst_'. &filetype, 'wbg', tlib#var#Get('tselectfiles_part_subst', 'wbg', {}))
+ for [pattern, substitution] in items(subst)
+ call map(parts, 'substitute(v:val, pattern, substitution, "g")')
+ endfor
+ call filter(parts, '!empty(v:val)')
+ let b:tselectfiles_filter_rx = join(parts, '\|')
return b:tselectfiles_filter_rx
endf
View
31 doc/tselectfiles.txt
@@ -19,7 +19,8 @@ b:tselectfile_filter_rx = expand('%:t:r'). Thus, when I open
:TSelectFiles shows all the files under "~/vimfiles" matching "foo".
Features:
- - list files, dynamically select files matching a pattern
+ - list files (recursively or the in the current directory only),
+ dynamically select files matching a pattern
- open files
- preview files
- rename/move files
@@ -28,6 +29,23 @@ Features:
- delete files
- show file info
+Advanced uses:
+
+Related files: If you set |g:tselectfiles_filter_rx| to some appropriate
+value, only files matching that regexp will be shown initially. This can
+be used to restrict the list to "related" files. (The initial filter can
+be removed by pressing <c-bs>.) See also |tselectfiles#BaseFilter()| and
+|g:tselectfiles_part_subst|.
+
+Rolodex: If a filename matches an entry in
+|g:tselectfiles_filedescription_rx| (a dictionnary patter => funcref),
+funcref(filename) will be called to retrieve the file's description.
+This function could be used to extract metadata or selected lines from
+the file etc. By mapping one record onto one file, you would get some
+sort of rolodex-like database. See
+|tselectfiles#FormatVikiMetaDataOrFirstLine()| for an example for
+viki/deplate (vimscript #861) formatted files.
+
-----------------------------------------------------------------------
Install~
@@ -53,6 +71,8 @@ Contents~
g:tselectfiles_use_cache ............ |g:tselectfiles_use_cache|
g:tselectfiles_no_cache_rx .......... |g:tselectfiles_no_cache_rx|
g:tselectfiles_filter_rx ............ |g:tselectfiles_filter_rx|
+ g:tselectfiles_part_subst ........... |g:tselectfiles_part_subst|
+ g:tselectfiles_part_subst_ruby ...... |g:tselectfiles_part_subst_ruby|
g:tselectfiles_limit ................ |g:tselectfiles_limit|
g:tselectfiles_filedescription_rx ... |g:tselectfiles_filedescription_rx|
g:tselectfiles_world ................ |g:tselectfiles_world|
@@ -80,6 +100,15 @@ g:tselectfiles_no_cache_rx (default: '')
g:tselectfiles_filter_rx (default: '')
Retain only files matching this rx. (per window, per buffer, global)
+ *g:tselectfiles_part_subst*
+g:tselectfiles_part_subst (default: {})
+ In |tselectfiles#BaseFilter()|, rewrite name parts according to these
+ rules.
+
+ *g:tselectfiles_part_subst_ruby*
+g:tselectfiles_part_subst_ruby (default: {'s$': '', '^\(controller\|test\|spec\)$': ''})
+ Poor man's singularize etc.
+
*g:tselectfiles_limit*
g:tselectfiles_limit (default: 0)
The max depth when globbing directories recursively. 0 = no limit.
View
17 plugin/tselectfiles.vim
@@ -3,8 +3,8 @@
" @Website: http://www.vim.org/account/profile.php?user_id=4037
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2007-04-16.
-" @Last Change: 2008-10-01.
-" @Revision: 522
+" @Last Change: 2008-10-16.
+" @Revision: 544
" GetLatestVimScripts: 1865 1 tselectfiles.vim
if &cp || exists("loaded_tselectfile")
@@ -14,7 +14,7 @@ if !exists('loaded_tlib') || loaded_tlib < 18
echoerr "tlib >= 0.18 is required"
finish
endif
-let loaded_tselectfile = 6
+let loaded_tselectfile = 7
" Whether to cache directory listings (in memory). (per buffer, global)
" If 0, disable the use of cached file listings all together.
@@ -27,6 +27,12 @@ TLet g:tselectfiles_no_cache_rx = ''
" Retain only files matching this rx. (per window, per buffer, global)
TLet g:tselectfiles_filter_rx = ''
+" In |tselectfiles#BaseFilter()|, rewrite name parts according to these
+" rules.
+TLet g:tselectfiles_part_subst = {}
+" Poor man's singularize etc.
+TLet g:tselectfiles_part_subst_ruby = {'s$': '', '^\(controller\|test\|spec\)$': ''}
+
" The max depth when globbing directories recursively. 0 = no limit.
TLet g:tselectfiles_limit = 0
@@ -43,6 +49,7 @@ TLet g:tselectfiles_world = {
\ 'scratch': '__ttoc__',
\ 'return_agent': 'tselectfiles#ViewFile',
\ 'display_format': 'tselectfiles#FormatEntry(world, %s)',
+ \ 'filter_format': 'tselectfiles#FormatFilter(world, %s)',
\ 'pick_last_item': 0,
\ 'key_handlers': [
\ {'key': 4, 'agent': 'tselectfiles#AgentDeleteFile', 'key_name': '<c-d>', 'help': 'Delete file(s)'},
@@ -179,3 +186,7 @@ rx in the current buffer's filename.
- [gbw]tselectfiles_limit variable
- Problem when browsing single directories
+0.7
+- NEW: g:tselectfiles_part_subst* variables.
+- NEW: [bg]:tselectfiles_filter_basename variable
+
Please sign in to comment.
Something went wrong with that request. Please try again.