dot_vim
This commit is contained in:
parent
f0510126ba
commit
7a7c647c22
212 changed files with 30625 additions and 30625 deletions
73
dot_vim/plugin/AppleT.vim
Normal file
73
dot_vim/plugin/AppleT.vim
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
function! AppleT(name)
|
||||
python << EOF
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
import vim
|
||||
|
||||
def walkIt(search):
|
||||
fullpath = os.path.expanduser(set_path)
|
||||
fullsearch = ".*%s.*" % ".*".join(search)
|
||||
fullsearch = re.sub(" ","[/.]", fullsearch)
|
||||
bsearch = re.sub(" ",".*[/.].*", search)
|
||||
exactsearch = "%s" % bsearch
|
||||
exclude = re.compile("\.quer$|\.resp$|\.pyc$")
|
||||
ignoredirs = [".svn", "_site-packages"]
|
||||
fullmatch = re.compile(fullsearch, re.I)
|
||||
exactmatch = re.compile(exactsearch, re.I)
|
||||
length = len(fullpath)
|
||||
|
||||
results = []
|
||||
exactresults = []
|
||||
|
||||
for root, dirs, files in os.walk(set_path):
|
||||
for x in ignoredirs:
|
||||
if x in dirs:
|
||||
dirs.remove(x)
|
||||
for f in files:
|
||||
filename = os.path.join(root,f)
|
||||
if exclude.search(filename):
|
||||
pass
|
||||
elif exactmatch.search(filename):
|
||||
exactresults.append("%s" % filename)
|
||||
elif fullmatch.search(filename):
|
||||
results.append("%s" % filename)
|
||||
|
||||
if len(results) == 0:
|
||||
return
|
||||
|
||||
def cmplen(x,y):
|
||||
return cmp(len(x), len(y))
|
||||
|
||||
results.sort(cmplen)
|
||||
exactresults.sort(cmplen)
|
||||
results = exactresults + results
|
||||
|
||||
for i, a in enumerate(results):
|
||||
print "%d: %s" % (i + 1, a[length:])
|
||||
|
||||
which = vim.eval('input("Which? ")')
|
||||
if re.match("^[0-9]+$", which) == None:
|
||||
return
|
||||
which = int(which) - 1
|
||||
vim.command("tabnew " + results[which])
|
||||
|
||||
thingtosearch = vim.eval("expand(a:name)")
|
||||
walkIt(thingtosearch)
|
||||
|
||||
EOF
|
||||
endfunction
|
||||
|
||||
function! AppleTSetPath(path)
|
||||
python << EOF
|
||||
import vim
|
||||
set_path = vim.eval("expand(a:path)")
|
||||
EOF
|
||||
endfunction
|
||||
|
||||
if !exists(":AppleTSetPath")
|
||||
command! -nargs=+ AppleTSetPath :call AppleTSetPath(<q-args>)
|
||||
endif
|
||||
if !exists(":CmdT")
|
||||
command! -nargs=+ CmdT :call AppleT(<q-args>)
|
||||
endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue