- update runtime files

This commit is contained in:
Karsten Hopp 2008-12-01 14:10:35 +00:00
parent 8201c87d9d
commit cf9f5abbd8
8 changed files with 12110 additions and 0 deletions

2449
filetype.vim Normal file

File diff suppressed because it is too large Load Diff

36
gzip.vim Normal file
View File

@ -0,0 +1,36 @@
" Vim plugin for editing compressed files.
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last Change: 2005 Jul 26
" Exit quickly when:
" - this plugin was already loaded
" - when 'compatible' is set
" - some autocommands are already taking care of compressed files
if exists("loaded_gzip") || &cp || exists("#BufReadPre#*.gz")
finish
endif
let loaded_gzip = 1
augroup gzip
" Remove all gzip autocommands
au!
" Enable editing of gzipped files.
" The functions are defined in autoload/gzip.vim.
"
" Set binary mode before reading the file.
" Use "gzip -d", gunzip isn't always available.
autocmd BufReadPre,FileReadPre *.gz,*.bz2,*.Z setlocal bin
autocmd BufReadPost,FileReadPost *.gz call gzip#read("gzip -dn")
autocmd BufReadPost,FileReadPost *.bz2 call gzip#read("bzip2 -d")
autocmd BufReadPost,FileReadPost *.Z call gzip#read("uncompress")
autocmd BufWritePost,FileWritePost *.gz call gzip#write("gzip")
autocmd BufWritePost,FileWritePost *.bz2 call gzip#write("bzip2")
autocmd BufWritePost,FileWritePost *.Z call gzip#write("compress -f")
autocmd FileAppendPre *.gz call gzip#appre("gzip -dn")
autocmd FileAppendPre *.bz2 call gzip#appre("bzip2 -d")
autocmd FileAppendPre *.Z call gzip#appre("uncompress")
autocmd FileAppendPost *.gz call gzip#write("gzip")
autocmd FileAppendPost *.bz2 call gzip#write("bzip2")
autocmd FileAppendPost *.Z call gzip#write("compress -f")
augroup END

8011
netrw.vim Normal file

File diff suppressed because it is too large Load Diff

361
netrwFileHandlers.vim Normal file
View File

@ -0,0 +1,361 @@
" netrwFileHandlers: contains various extension-based file handlers for
" netrw's browsers' x command ("eXecute launcher")
" Author: Charles E. Campbell, Jr.
" Date: Sep 30, 2008
" Version: 10
" Copyright: Copyright (C) 1999-2008 Charles E. Campbell, Jr. {{{1
" Permission is hereby granted to use and distribute this code,
" with or without modifications, provided that this copyright
" notice is copied with it. Like anything else that's free,
" netrwFileHandlers.vim is provided *as is* and comes with no
" warranty of any kind, either expressed or implied. In no
" event will the copyright holder be liable for any damages
" resulting from the use of this software.
"
" Rom 6:23 (WEB) For the wages of sin is death, but the free gift of God {{{1
" is eternal life in Christ Jesus our Lord.
" ---------------------------------------------------------------------
" Load Once: {{{1
if exists("g:loaded_netrwFileHandlers") || &cp
finish
endif
let g:loaded_netrwFileHandlers= "v10"
if v:version < 702
echohl WarningMsg
echo "***warning*** this version of netrwFileHandlers needs vim 7.2"
echohl Normal
finish
endif
let s:keepcpo= &cpo
set cpo&vim
" ---------------------------------------------------------------------
" netrwFileHandlers#Invoke: {{{1
fun! netrwFileHandlers#Invoke(exten,fname)
" call Dfunc("netrwFileHandlers#Invoke(exten<".a:exten."> fname<".a:fname.">)")
let fname= a:fname
" list of supported special characters. Consider rcs,v --- that can be
" supported with a NFH_rcsCOMMAv() handler
if a:fname =~ '[@:,$!=\-+%?;~]'
let specials= {
\ '@' : 'AT',
\ ':' : 'COLON',
\ ',' : 'COMMA',
\ '$' : 'DOLLAR',
\ '!' : 'EXCLAMATION',
\ '=' : 'EQUAL',
\ '-' : 'MINUS',
\ '+' : 'PLUS',
\ '%' : 'PERCENT',
\ '?' : 'QUESTION',
\ ';' : 'SEMICOLON',
\ '~' : 'TILDE'}
let fname= substitute(a:fname,'[@:,$!=\-+%?;~]','\=specials[submatch(0)]','ge')
" call Decho('fname<'.fname.'> done with dictionary')
endif
if a:exten != "" && exists("*NFH_".a:exten)
" support user NFH_*() functions
" call Decho("let ret= netrwFileHandlers#NFH_".a:exten.'("'.fname.'")')
exe "let ret= NFH_".a:exten.'("'.fname.'")'
elseif a:exten != "" && exists("*s:NFH_".a:exten)
" use builtin-NFH_*() functions
" call Decho("let ret= netrwFileHandlers#NFH_".a:exten.'("'.fname.'")')
exe "let ret= s:NFH_".a:exten.'("'.fname.'")'
endif
" call Dret("netrwFileHandlers#Invoke 0 : ret=".ret)
return 0
endfun
" ---------------------------------------------------------------------
" s:NFH_html: handles html when the user hits "x" when the {{{1
" cursor is atop a *.html file
fun! s:NFH_html(pagefile)
" call Dfunc("s:NFH_html(".a:pagefile.")")
let page= substitute(a:pagefile,'^','file://','')
if executable("mozilla")
" call Decho("executing !mozilla ".page)
exe "!mozilla ".shellescape(page,1)
elseif executable("netscape")
" call Decho("executing !netscape ".page)
exe "!netscape ".shellescape(page,1)
else
" call Dret("s:NFH_html 0")
return 0
endif
" call Dret("s:NFH_html 1")
return 1
endfun
" ---------------------------------------------------------------------
" s:NFH_htm: handles html when the user hits "x" when the {{{1
" cursor is atop a *.htm file
fun! s:NFH_htm(pagefile)
" call Dfunc("s:NFH_htm(".a:pagefile.")")
let page= substitute(a:pagefile,'^','file://','')
if executable("mozilla")
" call Decho("executing !mozilla ".page)
exe "!mozilla ".shellescape(page,1)
elseif executable("netscape")
" call Decho("executing !netscape ".page)
exe "!netscape ".shellescape(page,1)
else
" call Dret("s:NFH_htm 0")
return 0
endif
" call Dret("s:NFH_htm 1")
return 1
endfun
" ---------------------------------------------------------------------
" s:NFH_jpg: {{{1
fun! s:NFH_jpg(jpgfile)
" call Dfunc("s:NFH_jpg(jpgfile<".a:jpgfile.">)")
if executable("gimp")
exe "silent! !gimp -s ".shellescape(a:jpgfile,1)
elseif executable(expand("$SystemRoot")."/SYSTEM32/MSPAINT.EXE")
" call Decho("silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT ".escape(a:jpgfile," []|'"))
exe "!".expand("$SystemRoot")."/SYSTEM32/MSPAINT ".shellescape(a:jpgfile,1)
else
" call Dret("s:NFH_jpg 0")
return 0
endif
" call Dret("s:NFH_jpg 1")
return 1
endfun
" ---------------------------------------------------------------------
" s:NFH_gif: {{{1
fun! s:NFH_gif(giffile)
" call Dfunc("s:NFH_gif(giffile<".a:giffile.">)")
if executable("gimp")
exe "silent! !gimp -s ".shellescape(a:giffile,1)
elseif executable(expand("$SystemRoot")."/SYSTEM32/MSPAINT.EXE")
exe "silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT ".shellescape(a:giffile,1)
else
" call Dret("s:NFH_gif 0")
return 0
endif
" call Dret("s:NFH_gif 1")
return 1
endfun
" ---------------------------------------------------------------------
" s:NFH_png: {{{1
fun! s:NFH_png(pngfile)
" call Dfunc("s:NFH_png(pngfile<".a:pngfile.">)")
if executable("gimp")
exe "silent! !gimp -s ".shellescape(a:pngfile,1)
elseif executable(expand("$SystemRoot")."/SYSTEM32/MSPAINT.EXE")
exe "silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT ".shellescape(a:pngfile,1)
else
" call Dret("s:NFH_png 0")
return 0
endif
" call Dret("s:NFH_png 1")
return 1
endfun
" ---------------------------------------------------------------------
" s:NFH_pnm: {{{1
fun! s:NFH_pnm(pnmfile)
" call Dfunc("s:NFH_pnm(pnmfile<".a:pnmfile.">)")
if executable("gimp")
exe "silent! !gimp -s ".shellescape(a:pnmfile,1)
elseif executable(expand("$SystemRoot")."/SYSTEM32/MSPAINT.EXE")
exe "silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT ".shellescape(a:pnmfile,1)
else
" call Dret("s:NFH_pnm 0")
return 0
endif
" call Dret("s:NFH_pnm 1")
return 1
endfun
" ---------------------------------------------------------------------
" s:NFH_bmp: visualize bmp files {{{1
fun! s:NFH_bmp(bmpfile)
" call Dfunc("s:NFH_bmp(bmpfile<".a:bmpfile.">)")
if executable("gimp")
exe "silent! !gimp -s ".a:bmpfile
elseif executable(expand("$SystemRoot")."/SYSTEM32/MSPAINT.EXE")
exe "silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT ".shellescape(a:bmpfile,1)
else
" call Dret("s:NFH_bmp 0")
return 0
endif
" call Dret("s:NFH_bmp 1")
return 1
endfun
" ---------------------------------------------------------------------
" s:NFH_pdf: visualize pdf files {{{1
fun! s:NFH_pdf(pdf)
" call Dfunc("s:NFH_pdf(pdf<".a:pdf.">)")
if executable("gs")
exe 'silent! !gs '.shellescape(a:pdf,1)
elseif executable("pdftotext")
exe 'silent! pdftotext -nopgbrk '.shellescape(a:pdf,1)
else
" call Dret("s:NFH_pdf 0")
return 0
endif
" call Dret("s:NFH_pdf 1")
return 1
endfun
" ---------------------------------------------------------------------
" s:NFH_doc: visualize doc files {{{1
fun! s:NFH_doc(doc)
" call Dfunc("s:NFH_doc(doc<".a:doc.">)")
if executable("oowriter")
exe 'silent! !oowriter '.shellescape(a:doc,1)
redraw!
else
" call Dret("s:NFH_doc 0")
return 0
endif
" call Dret("s:NFH_doc 1")
return 1
endfun
" ---------------------------------------------------------------------
" s:NFH_sxw: visualize sxw files {{{1
fun! s:NFH_sxw(sxw)
" call Dfunc("s:NFH_sxw(sxw<".a:sxw.">)")
if executable("oowriter")
exe 'silent! !oowriter '.shellescape(a:sxw,1)
redraw!
else
" call Dret("s:NFH_sxw 0")
return 0
endif
" call Dret("s:NFH_sxw 1")
return 1
endfun
" ---------------------------------------------------------------------
" s:NFH_xls: visualize xls files {{{1
fun! s:NFH_xls(xls)
" call Dfunc("s:NFH_xls(xls<".a:xls.">)")
if executable("oocalc")
exe 'silent! !oocalc '.shellescape(a:xls,1)
redraw!
else
" call Dret("s:NFH_xls 0")
return 0
endif
" call Dret("s:NFH_xls 1")
return 1
endfun
" ---------------------------------------------------------------------
" s:NFH_ps: handles PostScript files {{{1
fun! s:NFH_ps(ps)
" call Dfunc("s:NFH_ps(ps<".a:ps.">)")
if executable("gs")
" call Decho("exe silent! !gs ".a:ps)
exe "silent! !gs ".shellescape(a:ps,1)
redraw!
elseif executable("ghostscript")
" call Decho("exe silent! !ghostscript ".a:ps)
exe "silent! !ghostscript ".shellescape(a:ps,1)
redraw!
elseif executable("gswin32")
" call Decho("exe silent! !gswin32 ".shellescape(a:ps,1))
exe "silent! !gswin32 ".shellescape(a:ps,1)
redraw!
else
" call Dret("s:NFH_ps 0")
return 0
endif
" call Dret("s:NFH_ps 1")
return 1
endfun
" ---------------------------------------------------------------------
" s:NFH_eps: handles encapsulated PostScript files {{{1
fun! s:NFH_eps(eps)
" call Dfunc("s:NFH_eps()")
if executable("gs")
exe "silent! !gs ".shellescape(a:eps,1)
redraw!
elseif executable("ghostscript")
exe "silent! !ghostscript ".shellescape(a:eps,1)
redraw!
elseif executable("ghostscript")
exe "silent! !ghostscript ".shellescape(a:eps,1)
redraw!
elseif executable("gswin32")
exe "silent! !gswin32 ".shellescape(a:eps,1)
redraw!
else
" call Dret("s:NFH_eps 0")
return 0
endif
" call Dret("s:NFH_eps 0")
return 1
endfun
" ---------------------------------------------------------------------
" s:NFH_fig: handles xfig files {{{1
fun! s:NFH_fig(fig)
" call Dfunc("s:NFH_fig()")
if executable("xfig")
exe "silent! !xfig ".a:fig
redraw!
else
" call Dret("s:NFH_fig 0")
return 0
endif
" call Dret("s:NFH_fig 1")
return 1
endfun
" ---------------------------------------------------------------------
" s:NFH_obj: handles tgif's obj files {{{1
fun! s:NFH_obj(obj)
" call Dfunc("s:NFH_obj()")
if has("unix") && executable("tgif")
exe "silent! !tgif ".a:obj
redraw!
else
" call Dret("s:NFH_obj 0")
return 0
endif
" call Dret("s:NFH_obj 1")
return 1
endfun
let &cpo= s:keepcpo
" ---------------------------------------------------------------------
" Modelines: {{{1
" vim: fdm=marker

159
netrwPlugin.vim Normal file
View File

@ -0,0 +1,159 @@
" netrwPlugin.vim: Handles file transfer and remote directory listing across a network
" PLUGIN SECTION
" Date: Aug 10, 2008
" Maintainer: Charles E Campbell, Jr <NdrOchip@ScampbellPfamily.AbizM-NOSPAM>
" GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim
" Copyright: Copyright (C) 1999-2008 Charles E. Campbell, Jr. {{{1
" Permission is hereby granted to use and distribute this code,
" with or without modifications, provided that this copyright
" notice is copied with it. Like anything else that's free,
" netrw.vim, netrwPlugin.vim, and netrwSettings.vim are provided
" *as is* and comes with no warranty of any kind, either
" expressed or implied. By using this plugin, you agree that
" in no event will the copyright holder be liable for any damages
" resulting from the use of this software.
"
" But be doers of the Word, and not only hearers, deluding your own selves {{{1
" (James 1:22 RSV)
" =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
" Load Once: {{{1
if &cp || exists("g:loaded_netrwPlugin")
finish
endif
let g:loaded_netrwPlugin = "v134"
if v:version < 702
echohl WarningMsg | echo "***netrw*** you need vim version 7.2 for this version of netrw" | echohl None
finish
endif
let s:keepcpo = &cpo
set cpo&vim
" ---------------------------------------------------------------------
" Public Interface: {{{1
" Local Browsing: {{{2
augroup FileExplorer
au!
au BufEnter * silent! call s:LocalBrowse(expand("<amatch>"))
if has("win32") || has("win95") || has("win64") || has("win16")
au BufEnter .* silent! call s:LocalBrowse(expand("<amatch>"))
endif
augroup END
" Network Browsing Reading Writing: {{{2
augroup Network
au!
if has("win32") || has("win95") || has("win64") || has("win16")
au BufReadCmd file://* exe "silent doau BufReadPre ".fnameescape(netrw#RFC2396(expand("<amatch>")))|exe 'e '.fnameescape(substitute(netrw#RFC2396(expand("<amatch>")),'file://\(.*\)','\1',""))|exe "bwipe ".fnameescape(expand("<amatch>"))|exe "silent doau BufReadPost ".fnameescape(netrw#RFC2396(expand("<amatch>")))
else
au BufReadCmd file://* exe "silent doau BufReadPre ".fnameescape(netrw#RFC2396(expand("<amatch>")))|exe 'e '.fnameescape(substitute(netrw#RFC2396(expand("<amatch>")),'file://\(.*\)','\1',""))|exe "bwipe ".fnameescape(expand("<amatch>"))|exe "silent doau BufReadPost ".fnameescape(netrw#RFC2396(expand("<amatch>")))
au BufReadCmd file://localhost/* exe "silent doau BufReadPre ".fnameescape(netrw#RFC2396(expand("<amatch>")))|exe 'e '.fnameescape(substitute(netrw#RFC2396(expand("<amatch>")),'file://localhost/\(.*\)','\1',""))|exe "bwipe ".fnameescape(substitute(expand("<amatch>"),'file://\(\k\+@\)\=','',''))|exe "silent doau BufReadPost ".fnameescape(netrw#RFC2396(expand("<amatch>")))
endif
au BufReadCmd ftp://*,rcp://*,scp://*,http://*,dav://*,davs://*,rsync://*,sftp://* exe "silent doau BufReadPre ".fnameescape(expand("<amatch>"))|exe '2Nread '.fnameescape(expand("<amatch>"))|exe "silent doau BufReadPost ".fnameescape(expand("<amatch>"))
au FileReadCmd ftp://*,rcp://*,scp://*,http://*,dav://*,davs://*,rsync://*,sftp://* exe "silent doau FileReadPre ".fnameescape(expand("<amatch>"))|exe 'Nread '.fnameescape(expand("<amatch>"))|exe "silent doau FileReadPost ".fnameescape(expand("<amatch>"))
au BufWriteCmd ftp://*,rcp://*,scp://*,dav://*,davs://*,rsync://*,sftp://* exe "silent doau BufWritePre ".fnameescape(expand("<amatch>"))|exe 'Nwrite '.fnameescape(expand("<amatch>"))|exe "silent doau BufWritePost ".fnameescape(expand("<amatch>"))
au FileWriteCmd ftp://*,rcp://*,scp://*,dav://*,davs://*,rsync://*,sftp://* exe "silent doau FileWritePre ".fnameescape(expand("<amatch>"))|exe "'[,']".'Nwrite '.fnameescape(expand("<amatch>"))|exe "silent doau FileWritePost ".fnameescape(expand("<amatch>"))
try
au SourceCmd ftp://*,rcp://*,scp://*,http://*,dav://*,davs://*,rsync://*,sftp://* exe 'Nsource '.fnameescape(expand("<amatch>"))
catch /^Vim\%((\a\+)\)\=:E216/
au SourcePre ftp://*,rcp://*,scp://*,http://*,dav://*,davs://*,rsync://*,sftp://* exe 'Nsource '.fnameescape(expand("<amatch>"))
endtry
augroup END
" Commands: :Nread, :Nwrite, :NetUserPass {{{2
com! -count=1 -nargs=* Nread call netrw#NetrwSavePosn()<bar>call netrw#NetRead(<count>,<f-args>)<bar>call netrw#NetrwRestorePosn()
com! -range=% -nargs=* Nwrite call netrw#NetrwSavePosn()<bar><line1>,<line2>call netrw#NetWrite(<f-args>)<bar>call netrw#NetrwRestorePosn()
com! -nargs=* NetUserPass call NetUserPass(<f-args>)
com! -nargs=* Nsource call netrw#NetrwSavePosn()<bar>call netrw#NetSource(<f-args>)<bar>call netrw#NetrwRestorePosn()
" Commands: :Explore, :Sexplore, Hexplore, Vexplore {{{2
com! -nargs=* -bar -bang -count=0 -complete=dir Explore call netrw#Explore(<count>,0,0+<bang>0,<q-args>)
com! -nargs=* -bar -bang -count=0 -complete=dir Sexplore call netrw#Explore(<count>,1,0+<bang>0,<q-args>)
com! -nargs=* -bar -bang -count=0 -complete=dir Hexplore call netrw#Explore(<count>,1,2+<bang>0,<q-args>)
com! -nargs=* -bar -bang -count=0 -complete=dir Vexplore call netrw#Explore(<count>,1,4+<bang>0,<q-args>)
com! -nargs=* -bar -count=0 -complete=dir Texplore call netrw#Explore(<count>,0,6 ,<q-args>)
com! -nargs=* -bar -bang Nexplore call netrw#Explore(-1,0,0,<q-args>)
com! -nargs=* -bar -bang Pexplore call netrw#Explore(-2,0,0,<q-args>)
" Commands: NetrwSettings {{{2
com! -nargs=0 NetrwSettings call netrwSettings#NetrwSettings()
com! -bang NetrwClean call netrw#NetrwClean(<bang>0)
" Maps:
if !exists("g:netrw_nogx") && maparg('g','n') == ""
if !hasmapto('<Plug>NetrwBrowseX')
nmap <unique> gx <Plug>NetrwBrowseX
endif
nno <silent> <Plug>NetrwBrowseX :call netrw#NetrwBrowseX(expand("<cWORD>"),0)<cr>
endif
" ---------------------------------------------------------------------
" LocalBrowse: {{{2
fun! s:LocalBrowse(dirname)
" unfortunate interaction -- debugging calls can't be used here;
" the BufEnter event causes triggering when attempts to write to
" the DBG buffer are made.
" echomsg "dirname<".a:dirname.">"
if has("amiga")
" The check against '' is made for the Amiga, where the empty
" string is the current directory and not checking would break
" things such as the help command.
if a:dirname != '' && isdirectory(a:dirname)
silent! call netrw#LocalBrowseCheck(a:dirname)
endif
elseif isdirectory(a:dirname)
" echomsg "dirname<".dirname."> isdir"
silent! call netrw#LocalBrowseCheck(a:dirname)
endif
" not a directory, ignore it
endfun
" ---------------------------------------------------------------------
" NetrwStatusLine: {{{1
fun! NetrwStatusLine()
" let g:stlmsg= "Xbufnr=".w:netrw_explore_bufnr." bufnr=".bufnr("%")." Xline#".w:netrw_explore_line." line#".line(".")
if !exists("w:netrw_explore_bufnr") || w:netrw_explore_bufnr != bufnr("%") || !exists("w:netrw_explore_line") || w:netrw_explore_line != line(".") || !exists("w:netrw_explore_list")
let &stl= s:netrw_explore_stl
if exists("w:netrw_explore_bufnr")|unlet w:netrw_explore_bufnr|endif
if exists("w:netrw_explore_line")|unlet w:netrw_explore_line|endif
return ""
else
return "Match ".w:netrw_explore_mtchcnt." of ".w:netrw_explore_listlen
endif
endfun
" ------------------------------------------------------------------------
" NetUserPass: set username and password for subsequent ftp transfer {{{1
" Usage: :call NetUserPass() -- will prompt for userid and password
" :call NetUserPass("uid") -- will prompt for password
" :call NetUserPass("uid","password") -- sets global userid and password
fun! NetUserPass(...)
" get/set userid
if a:0 == 0
" call Dfunc("NetUserPass(a:0<".a:0.">)")
if !exists("g:netrw_uid") || g:netrw_uid == ""
" via prompt
let g:netrw_uid= input('Enter username: ')
endif
else " from command line
" call Dfunc("NetUserPass(a:1<".a:1.">) {")
let g:netrw_uid= a:1
endif
" get password
if a:0 <= 1 " via prompt
" call Decho("a:0=".a:0." case <=1:")
let g:netrw_passwd= inputsecret("Enter Password: ")
else " from command line
" call Decho("a:0=".a:0." case >1: a:2<".a:2.">")
let g:netrw_passwd=a:2
endif
" call Dret("NetUserPass")
endfun
" ------------------------------------------------------------------------
" Modelines And Restoration: {{{1
let &cpo= s:keepcpo
unlet s:keepcpo
" vim:ts=8 fdm=marker

207
netrwSettings.vim Normal file
View File

@ -0,0 +1,207 @@
" netrwSettings.vim: makes netrw settings simpler
" Date: Sep 03, 2008
" Maintainer: Charles E Campbell, Jr <drchipNOSPAM at campbellfamily dot biz>
" Version: 13
" Copyright: Copyright (C) 1999-2007 Charles E. Campbell, Jr. {{{1
" Permission is hereby granted to use and distribute this code,
" with or without modifications, provided that this copyright
" notice is copied with it. Like anything else that's free,
" netrwSettings.vim is provided *as is* and comes with no
" warranty of any kind, either expressed or implied. By using
" this plugin, you agree that in no event will the copyright
" holder be liable for any damages resulting from the use
" of this software.
"
" Mat 4:23 (WEB) Jesus went about in all Galilee, teaching in their {{{1
" synagogues, preaching the gospel of the kingdom, and healing
" every disease and every sickness among the people.
" Load Once: {{{1
if exists("g:loaded_netrwSettings") || &cp
finish
endif
let g:loaded_netrwSettings = "v13"
if v:version < 700
echohl WarningMsg
echo "***warning*** this version of netrwSettings needs vim 7.0"
echohl Normal
finish
endif
" ---------------------------------------------------------------------
" NetrwSettings: {{{1
fun! netrwSettings#NetrwSettings()
" this call is here largely just to insure that netrw has been loaded
call netrw#NetrwSavePosn()
if !exists("g:loaded_netrw")
echohl WarningMsg | echomsg "***sorry*** netrw needs to be loaded prior to using NetrwSettings" | echohl None
return
endif
above wincmd s
enew
setlocal noswapfile bh=wipe
set ft=vim
file Netrw\ Settings
" these variables have the following default effects when they don't
" exist (ie. have not been set by the user in his/her .vimrc)
if !exists("g:netrw_liststyle")
let g:netrw_liststyle= 0
let g:netrw_list_cmd= "ssh HOSTNAME ls -FLa"
endif
if !exists("g:netrw_silent")
let g:netrw_silent= 0
endif
if !exists("g:netrw_use_nt_rcp")
let g:netrw_use_nt_rcp= 0
endif
if !exists("g:netrw_ftp")
let g:netrw_ftp= 0
endif
if !exists("g:netrw_ignorenetrc")
let g:netrw_ignorenetrc= 0
endif
put ='+ ---------------------------------------------'
put ='+ NetrwSettings: by Charles E. Campbell, Jr.'
put ='+ Press <F1> with cursor atop any line for help'
put ='+ ---------------------------------------------'
let s:netrw_settings_stop= line(".")
put =''
put ='+ Netrw Protocol Commands'
put = 'let g:netrw_dav_cmd = '.g:netrw_dav_cmd
put = 'let g:netrw_fetch_cmd = '.g:netrw_fetch_cmd
put = 'let g:netrw_ftp_cmd = '.g:netrw_ftp_cmd
put = 'let g:netrw_http_cmd = '.g:netrw_http_cmd
put = 'let g:netrw_rcp_cmd = '.g:netrw_rcp_cmd
put = 'let g:netrw_rsync_cmd = '.g:netrw_rsync_cmd
put = 'let g:netrw_scp_cmd = '.g:netrw_scp_cmd
put = 'let g:netrw_sftp_cmd = '.g:netrw_sftp_cmd
put = 'let g:netrw_ssh_cmd = '.g:netrw_ssh_cmd
let s:netrw_protocol_stop= line(".")
put = ''
put ='+Netrw Transfer Control'
put = 'let g:netrw_cygwin = '.g:netrw_cygwin
put = 'let g:netrw_ftp = '.g:netrw_ftp
put = 'let g:netrw_ftpmode = '.g:netrw_ftpmode
put = 'let g:netrw_ignorenetrc = '.g:netrw_ignorenetrc
put = 'let g:netrw_sshport = '.g:netrw_sshport
put = 'let g:netrw_use_nt_rcp = '.g:netrw_use_nt_rcp
put = 'let g:netrw_win95ftp = '.g:netrw_win95ftp
let s:netrw_xfer_stop= line(".")
put =''
put ='+ Netrw Messages'
put ='let g:netrw_use_errorwindow = '.g:netrw_use_errorwindow
put = ''
put ='+ Netrw Browser Control'
put = 'let g:netrw_alto = '.g:netrw_alto
put = 'let g:netrw_altv = '.g:netrw_altv
put = 'let g:netrw_browse_split = '.g:netrw_browse_split
if exists("g:netrw_browsex_viewer")
put = 'let g:netrw_browsex_viewer = '.g:netrw_browsex_viewer
else
put = 'let g:netrw_browsex_viewer = (not defined)'
endif
put = 'let g:netrw_compress = '.g:netrw_compress
put = 'let g:netrw_cursorline = '.g:netrw_cursorline
let decompressline= line("$")
put ='let g:netrw_decompress...'
put = 'let g:netrw_dirhistmax = '.g:netrw_dirhistmax
put = 'let g:netrw_fastbrowse = '.g:netrw_fastbrowse
let fnameescline= line("$")
put = 'let g:netrw_fname_escape...'
put = 'let g:netrw_ftp_browse_reject = '.g:netrw_ftp_browse_reject
put = 'let g:netrw_ftp_list_cmd = '.g:netrw_ftp_list_cmd
put = 'let g:netrw_ftp_sizelist_cmd = '.g:netrw_ftp_sizelist_cmd
put = 'let g:netrw_ftp_timelist_cmd = '.g:netrw_ftp_timelist_cmd
let globescline= line("$")
put ='let g:netrw_glob_escape...'
put = 'let g:netrw_hide = '.g:netrw_hide
put = 'let g:netrw_keepdir = '.g:netrw_keepdir
put = 'let g:netrw_list_cmd = '.g:netrw_list_cmd
put = 'let g:netrw_list_hide = '.g:netrw_list_hide
put = 'let g:netrw_liststyle = '.g:netrw_liststyle
put = 'let g:netrw_localcopycmd = '.g:netrw_localcopycmd
put = 'let g:netrw_local_mkdir = '.g:netrw_local_mkdir
put = 'let g:netrw_localmovecmd = '.g:netrw_localmovecmd
put = 'let g:netrw_local_rmdir = '.g:netrw_local_rmdir
put = 'let g:netrw_maxfilenamelen = '.g:netrw_maxfilenamelen
put = 'let g:netrw_menu = '.g:netrw_menu
put = 'let g:netrw_mkdir_cmd = '.g:netrw_mkdir_cmd
put = 'let g:netrw_preview = '.g:netrw_preview
put = 'let g:netrw_rename_cmd = '.g:netrw_rename_cmd
put = 'let g:netrw_retmap = '.g:netrw_retmap
put = 'let g:netrw_rm_cmd = '.g:netrw_rm_cmd
put = 'let g:netrw_rmdir_cmd = '.g:netrw_rmdir_cmd
put = 'let g:netrw_rmf_cmd = '.g:netrw_rmf_cmd
put = 'let g:netrw_silent = '.g:netrw_silent
put = 'let g:netrw_sort_by = '.g:netrw_sort_by
put = 'let g:netrw_sort_direction = '.g:netrw_sort_direction
put = 'let g:netrw_sort_options = '.g:netrw_sort_options
put = 'let g:netrw_sort_sequence = '.g:netrw_sort_sequence
put = 'let g:netrw_special_syntax = '.g:netrw_special_syntax
put = 'let g:netrw_ssh_browse_reject = '.g:netrw_ssh_browse_reject
put = 'let g:netrw_scpport = '.g:netrw_scpport
put = 'let g:netrw_sshport = '.g:netrw_sshport
put = 'let g:netrw_timefmt = '.g:netrw_timefmt
let tmpfileescline= line("$")
put ='let g:netrw_tmpfile_escape...'
put = 'let g:netrw_use_noswf = '.g:netrw_use_noswf
put = 'let g:netrw_xstrlen = '.g:netrw_xstrlen
put = 'let g:netrw_winsize = '.g:netrw_winsize
put =''
put ='+ For help, place cursor on line and press <F1>'
1d
silent %s/^+/"/e
res 99
silent %s/= \([^0-9].*\)$/= '\1'/e
silent %s/= $/= ''/e
1
call setline(decompressline,"let g:netrw_decompress = ".substitute(string(g:netrw_decompress),"^'\\(.*\\)'$",'\1',''))
call setline(fnameescline, "let g:netrw_fname_escape = '".escape(g:netrw_fname_escape,"'")."'")
call setline(globescline, "let g:netrw_glob_escape = '".escape(g:netrw_glob_escape,"'")."'")
call setline(tmpfileescline,"let g:netrw_tmpfile_escape = '".escape(g:netrw_tmpfile_escape,"'")."'")
set nomod
nmap <buffer> <silent> <F1> :call NetrwSettingHelp()<cr>
nnoremap <buffer> <silent> <leftmouse> <leftmouse>:call NetrwSettingHelp()<cr>
let tmpfile= tempname()
exe 'au BufWriteCmd Netrw\ Settings silent w! '.tmpfile.'|so '.tmpfile.'|call delete("'.tmpfile.'")|set nomod'
endfun
" ---------------------------------------------------------------------
" NetrwSettingHelp: {{{2
fun! NetrwSettingHelp()
" call Dfunc("NetrwSettingHelp()")
let curline = getline(".")
if curline =~ '='
let varhelp = substitute(curline,'^\s*let ','','e')
let varhelp = substitute(varhelp,'\s*=.*$','','e')
" call Decho("trying help ".varhelp)
try
exe "he ".varhelp
catch /^Vim\%((\a\+)\)\=:E149/
echo "***sorry*** no help available for <".varhelp.">"
endtry
elseif line(".") < s:netrw_settings_stop
he netrw-settings
elseif line(".") < s:netrw_protocol_stop
he netrw-externapp
elseif line(".") < s:netrw_xfer_stop
he netrw-variables
else
he netrw-browse-var
endif
" call Dret("NetrwSettingHelp")
endfun
" ---------------------------------------------------------------------
" Modelines: {{{1
" vim:ts=8 fdm=marker

500
tar.vim Normal file
View File

@ -0,0 +1,500 @@
" tar.vim: Handles browsing tarfiles
" AUTOLOAD PORTION
" Date: Aug 08, 2008
" Version: 23 + modifications by Bram
" Maintainer: Charles E Campbell, Jr <NdrOchip@ScampbellPfamily.AbizM-NOSPAM>
" License: Vim License (see vim's :help license)
"
" Contains many ideas from Michael Toren's <tar.vim>
"
" Copyright: Copyright (C) 2005-2008 Charles E. Campbell, Jr. {{{1
" Permission is hereby granted to use and distribute this code,
" with or without modifications, provided that this copyright
" notice is copied with it. Like anything else that's free,
" tar.vim and tarPlugin.vim are provided *as is* and comes
" with no warranty of any kind, either expressed or implied.
" By using this plugin, you agree that in no event will the
" copyright holder be liable for any damages resulting from
" the use of this software.
" ---------------------------------------------------------------------
" Load Once: {{{1
let s:keepcpo= &cpo
set cpo&vim
if &cp || exists("g:loaded_tar") || v:version < 700
finish
endif
let g:loaded_tar= "v23b"
"call Decho("loading autoload/tar.vim")
if v:version < 701 || (v:version == 701 && !has("patch299"))
echoerr "(autoload/tar.vim) need vim v7.1 with patchlevel 299"
endif
" ---------------------------------------------------------------------
" Default Settings: {{{1
if !exists("g:tar_browseoptions")
let g:tar_browseoptions= "Ptf"
endif
if !exists("g:tar_readoptions")
let g:tar_readoptions= "OPxf"
endif
if !exists("g:tar_cmd")
let g:tar_cmd= "tar"
endif
if !exists("g:tar_writeoptions")
let g:tar_writeoptions= "uf"
endif
if !exists("g:netrw_cygwin")
if has("win32") || has("win95") || has("win64") || has("win16")
if &shell =~ '\%(\<bash\>\|\<zsh\>\)\%(\.exe\)\=$'
let g:netrw_cygwin= 1
else
let g:netrw_cygwin= 0
endif
else
let g:netrw_cygwin= 0
endif
endif
" set up shell quoting character
if !exists("g:tar_shq")
if exists("&shq") && &shq != ""
let g:tar_shq= &shq
elseif has("win32") || has("win95") || has("win64") || has("win16")
if exists("g:netrw_cygwin") && g:netrw_cygwin
let g:tar_shq= "'"
else
let g:tar_shq= '"'
endif
else
let g:tar_shq= "'"
endif
" call Decho("g:tar_shq<".g:tar_shq.">")
endif
" ----------------
" Functions: {{{1
" ----------------
" ---------------------------------------------------------------------
" tar#Browse: {{{2
fun! tar#Browse(tarfile)
" call Dfunc("tar#Browse(tarfile<".a:tarfile.">)")
let repkeep= &report
set report=10
" sanity checks
if !executable(g:tar_cmd)
redraw!
echohl Error | echo '***error*** (tar#Browse) "'.g:tar_cmd.'" not available on your system'
" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
let &report= repkeep
" call Dret("tar#Browse")
return
endif
if !filereadable(a:tarfile)
" call Decho('a:tarfile<'.a:tarfile.'> not filereadable')
if a:tarfile !~# '^\a\+://'
" if its an url, don't complain, let url-handlers such as vim do its thing
redraw!
echohl Error | echo "***error*** (tar#Browse) File not readable<".a:tarfile.">" | echohl None
" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
endif
let &report= repkeep
" call Dret("tar#Browse : file<".a:tarfile."> not readable")
return
endif
if &ma != 1
set ma
endif
let w:tarfile= a:tarfile
setlocal noswapfile
setlocal buftype=nofile
setlocal bufhidden=hide
setlocal nobuflisted
setlocal nowrap
set ft=tar
" give header
" call Decho("printing header")
let lastline= line("$")
call setline(lastline+1,'" tar.vim version '.g:loaded_tar)
call setline(lastline+2,'" Browsing tarfile '.a:tarfile)
call setline(lastline+3,'" Select a file with cursor and press ENTER')
$put =''
0d
$
let tarfile= a:tarfile
if has("win32") && executable("cygpath")
" assuming cygwin
let tarfile=substitute(system("cygpath -u ".s:Escape(tarfile,0)),'\n$','','e')
endif
let curlast= line("$")
if tarfile =~# '\.\(gz\|tgz\)$'
" call Decho("1: exe silent r! gzip -d -c -- ".s:Escape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - ")
exe "silent r! gzip -d -c -- ".s:Escape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
elseif tarfile =~# '\.lrp'
" call Decho("2: exe silent r! cat -- ".s:Escape(tarfile,1)."|gzip -d -c -|".g:tar_cmd." -".g:tar_browseoptions." - ")
exe "silent r! cat -- ".s:Escape(tarfile,1)."|gzip -d -c -|".g:tar_cmd." -".g:tar_browseoptions." - "
elseif tarfile =~# '\.bz2$'
" call Decho("3: exe silent r! bzip2 -d -c -- ".s:Escape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - ")
exe "silent r! bzip2 -d -c -- ".s:Escape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
else
if tarfile =~ '^\s*-'
" A file name starting with a dash may be taken as an option. Prepend ./ to avoid that.
let tarfile = substitute(tarfile, '-', './-', '')
endif
" call Decho("4: exe silent r! ".g:tar_cmd." -".g:tar_browseoptions." ".s:Escape(tarfile,1))
exe "silent r! ".g:tar_cmd." -".g:tar_browseoptions." ".s:Escape(tarfile,1)
endif
if v:shell_error != 0
redraw!
echohl WarningMsg | echo "***warning*** (tar#Browse) please check your g:tar_browseoptions<".g:tar_browseoptions.">"
" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
" call Dret("tar#Browse : a:tarfile<".a:tarfile.">")
return
endif
if line("$") == curlast || ( line("$") == (curlast + 1) && getline("$") =~ '\c\%(warning\|error\|inappropriate\|unrecognized\)')
redraw!
echohl WarningMsg | echo "***warning*** (tar#Browse) ".a:tarfile." doesn't appear to be a tar file" | echohl None
" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
silent %d
let eikeep= &ei
set ei=BufReadCmd,FileReadCmd
exe "r ".fnameescape(a:tarfile)
let &ei= eikeep
1d
" call Dret("tar#Browse : a:tarfile<".a:tarfile.">")
return
endif
setlocal noma nomod ro
noremap <silent> <buffer> <cr> :call <SID>TarBrowseSelect()<cr>
let &report= repkeep
" call Dret("tar#Browse : w:tarfile<".w:tarfile.">")
endfun
" ---------------------------------------------------------------------
" TarBrowseSelect: {{{2
fun! s:TarBrowseSelect()
" call Dfunc("TarBrowseSelect() w:tarfile<".w:tarfile."> curfile<".expand("%").">")
let repkeep= &report
set report=10
let fname= getline(".")
" call Decho("fname<".fname.">")
if !exists("g:tar_secure") && fname =~ '^\s*-\|\s\+-'
redraw!
echohl WarningMsg | echo '***error*** (tar#BrowseSelect) rejecting tarfile member<'.fname.'> because of embedded "-"; See :help tar-options'
" call Dret('tar#BrowseSelect : rejecting tarfile member<'.fname.'> because of embedded "-"')
return
endif
" sanity check
if fname =~ '^"'
let &report= repkeep
" call Dret("TarBrowseSelect")
return
endif
" about to make a new window, need to use w:tarfile
let tarfile= w:tarfile
let curfile= expand("%")
if has("win32") && executable("cygpath")
" assuming cygwin
let tarfile=substitute(system("cygpath -u ".s:Escape(tarfile,0)),'\n$','','e')
endif
new
if !exists("g:tar_nomax") || g:tar_nomax == 0
wincmd _
endif
let s:tblfile_{winnr()}= curfile
call tar#Read("tarfile:".tarfile.'::'.fname,1)
filetype detect
let &report= repkeep
" call Dret("TarBrowseSelect : s:tblfile_".winnr()."<".s:tblfile_{winnr()}.">")
endfun
" ---------------------------------------------------------------------
" tar#Read: {{{2
fun! tar#Read(fname,mode)
" call Dfunc("tar#Read(fname<".a:fname.">,mode=".a:mode.")")
let repkeep= &report
set report=10
let tarfile = substitute(a:fname,'tarfile:\(.\{-}\)::.*$','\1','')
let fname = substitute(a:fname,'tarfile:.\{-}::\(.*\)$','\1','')
if has("win32") && executable("cygpath")
" assuming cygwin
let tarfile=substitute(system("cygpath -u ".s:Escape(tarfile,0)),'\n$','','e')
endif
" call Decho("tarfile<".tarfile.">")
" call Decho("fname<".fname.">")
if fname =~ '\.gz$' && executable("zcat")
let decmp= "|zcat"
let doro = 1
elseif fname =~ '\.bz2$' && executable("bzcat")
let decmp= "|bzcat"
let doro = 1
else
let decmp=""
let doro = 0
if fname =~ '\.gz$\|\.bz2$\|\.Z$\|\.zip$'
setlocal bin
endif
endif
if exists("g:tar_secure")
let tar_secure= " -- "
else
let tar_secure= " "
endif
if tarfile =~# '\.\(gz\|tgz\)$'
" call Decho("5: exe silent r! gzip -d -c -- ".s:Escape(tarfile,1)."| ".g:tar_cmd.' -'.g:tar_readoptions.' - '.tar_secure.s:Escape(fname,1))
exe "silent r! gzip -d -c -- ".s:Escape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.s:Escape(fname,1).decmp
elseif tarfile =~# '\.lrp$'
" call Decho("6: exe silent r! cat ".s:Escape(tarfile,1)." | gzip -d -c - | ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.s:Escape(fname,1).decmp)
exe "silent r! cat -- ".s:Escape(tarfile,1)." | gzip -d -c - | ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.s:Escape(fname,1).decmp
elseif tarfile =~# '\.bz2$'
" call Decho("7: exe silent r! bzip2 -d -c ".s:Escape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.s:Escape(fname,1).decmp)
exe "silent r! bzip2 -d -c -- ".s:Escape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.s:Escape(fname,1).decmp
else
if tarfile =~ '^\s*-'
" A file name starting with a dash may be taken as an option. Prepend ./ to avoid that.
let tarfile = substitute(tarfile, '-', './-', '')
endif
" call Decho("8: exe silent r! ".g:tar_cmd." -".g:tar_readoptions." "s:Escape(tarfile,1).tar_secure..s:Escape(fname,1).decmp)
exe "silent r! ".g:tar_cmd." -".g:tar_readoptions." ".s:Escape(tarfile,1).tar_secure.s:Escape(fname,1).decmp
endif
if doro
" because the reverse process of compressing changed files back into the tarball is not currently supported
setlocal ro
endif
let w:tarfile= a:fname
exe "file tarfile::".fnameescape(fname)
" cleanup
0d
set nomod
let &report= repkeep
" call Dret("tar#Read : w:tarfile<".w:tarfile.">")
endfun
" ---------------------------------------------------------------------
" tar#Write: {{{2
fun! tar#Write(fname)
" call Dfunc("tar#Write(fname<".a:fname.">) w:tarfile<".w:tarfile."> tblfile_".winnr()."<".s:tblfile_{winnr()}.">")
let repkeep= &report
set report=10
if !exists("g:tar_secure") && a:fname =~ '^\s*-\|\s\+-'
redraw!
echohl WarningMsg | echo '***error*** (tar#Write) rejecting tarfile member<'.a:fname.'> because of embedded "-"; See :help tar-options'
" call Dret('tar#Write : rejecting tarfile member<'.fname.'> because of embedded "-"')
return
endif
" sanity checks
if !executable(g:tar_cmd)
redraw!
echohl Error | echo '***error*** (tar#Browse) "'.g:tar_cmd.'" not available on your system'
" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
let &report= repkeep
" call Dret("tar#Write")
return
endif
if !exists("*mkdir")
redraw!
echohl Error | echo "***error*** (tar#Write) sorry, mkdir() doesn't work on your system" | echohl None
" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
let &report= repkeep
" call Dret("tar#Write")
return
endif
let curdir= getcwd()
let tmpdir= tempname()
" call Decho("orig tempname<".tmpdir.">")
if tmpdir =~ '\.'
let tmpdir= substitute(tmpdir,'\.[^.]*$','','e')
endif
" call Decho("tmpdir<".tmpdir.">")
call mkdir(tmpdir,"p")
" attempt to change to the indicated directory
try
exe "cd ".fnameescape(tmpdir)
catch /^Vim\%((\a\+)\)\=:E344/
redraw!
echohl Error | echo "***error*** (tar#Write) cannot cd to temporary directory" | Echohl None
" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
let &report= repkeep
" call Dret("tar#Write")
return
endtry
" call Decho("current directory now: ".getcwd())
" place temporary files under .../_ZIPVIM_/
if isdirectory("_ZIPVIM_")
call s:Rmdir("_ZIPVIM_")
endif
call mkdir("_ZIPVIM_")
cd _ZIPVIM_
" call Decho("current directory now: ".getcwd())
let tarfile = substitute(w:tarfile,'tarfile:\(.\{-}\)::.*$','\1','')
let fname = substitute(w:tarfile,'tarfile:.\{-}::\(.*\)$','\1','')
" handle compressed archives
if tarfile =~# '\.gz'
call system("gzip -d -- ".s:Escape(tarfile,0))
let tarfile = substitute(tarfile,'\.gz','','e')
let compress= "gzip -- ".s:Escape(tarfile,0)
" call Decho("compress<".compress.">")
elseif tarfile =~# '\.tgz'
call system("gzip -d -- ".s:Escape(tarfile,0))
let tarfile = substitute(tarfile,'\.tgz','.tar','e')
let compress= "gzip -- ".s:Escape(tarfile,0)
let tgz = 1
" call Decho("compress<".compress.">")
elseif tarfile =~# '\.bz2'
call system("bzip2 -d -- ".s:Escape(tarfile,0))
let tarfile = substitute(tarfile,'\.bz2','','e')
let compress= "bzip2 -- ".s:Escape(tarfile,0)
" call Decho("compress<".compress.">")
endif
" call Decho("tarfile<".tarfile.">")
if v:shell_error != 0
redraw!
echohl Error | echo "***error*** (tar#Write) sorry, unable to update ".tarfile." with ".fname | echohl None
" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
else
" call Decho("tarfile<".tarfile."> fname<".fname.">")
if fname =~ '/'
let dirpath = substitute(fname,'/[^/]\+$','','e')
if executable("cygpath")
let dirpath = substitute(system("cygpath ".s:Escape(dirpath, 0)),'\n','','e')
endif
call mkdir(dirpath,"p")
endif
if tarfile !~ '/'
let tarfile= curdir.'/'.tarfile
endif
if tarfile =~ '^\s*-'
" A file name starting with a dash may be taken as an option. Prepend ./ to avoid that.
let tarfile = substitute(tarfile, '-', './-', '')
endif
" call Decho("tarfile<".tarfile."> fname<".fname.">")
if exists("g:tar_secure")
let tar_secure= " -- "
else
let tar_secure= " "
endif
exe "w! ".fnameescape(fname)
if executable("cygpath")
let tarfile = substitute(system("cygpath ".s:Escape(tarfile,0)),'\n','','e')
endif
" delete old file from tarfile
" call Decho("system(".g:tar_cmd." --delete -f ".s:Escape(tarfile,0)." -- ".s:Escape(fname,0).")")
call system(g:tar_cmd." --delete -f ".s:Escape(tarfile,0).tar_secure.s:Escape(fname,0))
if v:shell_error != 0
redraw!
echohl Error | echo "***error*** (tar#Write) sorry, unable to update ".fnameescape(tarfile)." with ".fnameescape(fname) | echohl None
" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
else
" update tarfile with new file
" call Decho(g:tar_cmd." -".g:tar_writeoptions." ".s:Escape(tarfile,0).tar_secure.s:Escape(fname,0))
call system(g:tar_cmd." -".g:tar_writeoptions." ".s:Escape(tarfile,0).tar_secure.s:Escape(fname,0))
if v:shell_error != 0
redraw!
echohl Error | echo "***error*** (tar#Write) sorry, unable to update ".fnameescape(tarfile)." with ".fnameescape(fname) | echohl None
" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
elseif exists("compress")
" call Decho("call system(".compress.")")
call system(compress)
if exists("tgz")
" call Decho("rename(".tarfile.".gz,".substitute(tarfile,'\.tar$','.tgz','e').")")
call rename(tarfile.".gz",substitute(tarfile,'\.tar$','.tgz','e'))
endif
endif
endif
" support writing tarfiles across a network
if s:tblfile_{winnr()} =~ '^\a\+://'
" call Decho("handle writing <".tarfile."> across network to <".s:tblfile_{winnr()}.">")
let tblfile= s:tblfile_{winnr()}
1split|enew
let binkeep= &binary
let eikeep = &ei
set binary ei=all
exe "e! ".fnameescape(tarfile)
call netrw#NetWrite(tblfile)
let &ei = eikeep
let &binary = binkeep
q!
unlet s:tblfile_{winnr()}
endif
endif
" cleanup and restore current directory
cd ..
call s:Rmdir("_ZIPVIM_")
exe "cd ".fnameescape(curdir)
setlocal nomod
let &report= repkeep
" call Dret("tar#Write")
endfun
" ---------------------------------------------------------------------
" Rmdir: {{{2
fun! s:Rmdir(fname)
" call Dfunc("Rmdir(fname<".a:fname.">)")
if has("unix")
call system("/bin/rm -rf -- ".s:Escape(a:fname,0))
elseif has("win32") || has("win95") || has("win64") || has("win16")
if &shell =~? "sh$"
call system("/bin/rm -rf -- ".s:Escape(a:fname,0))
else
call system("del /S ".s:Escape(a:fname,0))
endif
endif
" call Dret("Rmdir")
endfun
" ---------------------------------------------------------------------
" s:Escape: {{{2
fun s:Escape(name,isfilt)
" shellescape() was added by patch 7.0.111
if exists("*shellescape")
if a:isfilt
let qnameq= shellescape(a:name,1)
else
let qnameq= shellescape(a:name)
endif
else
let qnameq= g:tar_shq . a:name . g:tar_shq
endif
return qnameq
endfun
" ---------------------------------------------------------------------
" Modelines And Restoration: {{{1
let &cpo= s:keepcpo
unlet s:keepcpo
" vim:ts=8 fdm=marker

387
zip.vim Normal file
View File

@ -0,0 +1,387 @@
" zip.vim: Handles browsing zipfiles
" AUTOLOAD PORTION
" Date: Jul 30, 2008
" Version: 22
" Maintainer: Charles E Campbell, Jr <NdrOchip@ScampbellPfamily.AbizM-NOSPAM>
" License: Vim License (see vim's :help license)
" Copyright: Copyright (C) 2005-2008 Charles E. Campbell, Jr. {{{1
" Permission is hereby granted to use and distribute this code,
" with or without modifications, provided that this copyright
" notice is copied with it. Like anything else that's free,
" zip.vim and zipPlugin.vim are provided *as is* and comes with
" no warranty of any kind, either expressed or implied. By using
" this plugin, you agree that in no event will the copyright
" holder be liable for any damages resulting from the use
" of this software.
" ---------------------------------------------------------------------
" Load Once: {{{1
let s:keepcpo= &cpo
set cpo&vim
if &cp || exists("g:loaded_zip") || v:version < 700
finish
endif
let g:loaded_zip = "v22"
let s:zipfile_escape = ' ?&;\'
let s:ERROR = 2
let s:WARNING = 1
let s:NOTE = 0
" ---------------------------------------------------------------------
" Global Values: {{{1
if !exists("g:zip_shq")
if &shq != ""
let g:zip_shq= &shq
elseif has("unix")
let g:zip_shq= "'"
else
let g:zip_shq= '"'
endif
endif
if !exists("g:zip_zipcmd")
let g:zip_zipcmd= "zip"
endif
if !exists("g:zip_unzipcmd")
let g:zip_unzipcmd= "unzip"
endif
" ----------------
" Functions: {{{1
" ----------------
" ---------------------------------------------------------------------
" zip#Browse: {{{2
fun! zip#Browse(zipfile)
" call Dfunc("zip#Browse(zipfile<".a:zipfile.">)")
let repkeep= &report
set report=10
" sanity checks
if !exists("*fnameescape")
if &verbose > 1
echoerr "the zip plugin is not available (your vim doens't support fnameescape())"
endif
return
endif
if !executable(g:zip_unzipcmd)
redraw!
echohl Error | echo "***error*** (zip#Browse) unzip not available on your system"
" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
let &report= repkeep
" call Dret("zip#Browse")
return
endif
if !filereadable(a:zipfile)
if a:zipfile !~# '^\a\+://'
" if its an url, don't complain, let url-handlers such as vim do its thing
redraw!
echohl Error | echo "***error*** (zip#Browse) File not readable<".a:zipfile.">" | echohl None
" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
endif
let &report= repkeep
" call Dret("zip#Browse : file<".a:zipfile."> not readable")
return
endif
" call Decho("passed sanity checks")
if &ma != 1
set ma
endif
let b:zipfile= a:zipfile
setlocal noswapfile
setlocal buftype=nofile
setlocal bufhidden=hide
setlocal nobuflisted
setlocal nowrap
set ft=tar
" give header
let lastline= line("$")
call setline(lastline+1,'" zip.vim version '.g:loaded_zip)
call setline(lastline+2,'" Browsing zipfile '.a:zipfile)
call setline(lastline+3,'" Select a file with cursor and press ENTER')
$put =''
0d
$
" call Decho("exe silent r! ".g:zip_unzipcmd." -l -- ".s:Escape(a:zipfile,1))
exe "silent r! ".g:zip_unzipcmd." -l -- ".s:Escape(a:zipfile,1)
if v:shell_error != 0
redraw!
echohl WarningMsg | echo "***warning*** (zip#Browse) ".fnameescape(a:zipfile)." is not a zip file" | echohl None
" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
silent %d
let eikeep= &ei
set ei=BufReadCmd,FileReadCmd
exe "r ".fnameescape(a:zipfile)
let &ei= eikeep
1d
" call Dret("zip#Browse")
return
endif
" call Decho("line 6: ".getline(6))
let namecol= stridx(getline(6),'Name') + 1
" call Decho("namecol=".namecol)
4,$g/^\s*----/d
4,$g/^\s*\a/d
$d
if namecol > 0
exe 'silent 4,$s/^.*\%'.namecol.'c//'
endif
setlocal noma nomod ro
noremap <silent> <buffer> <cr> :call <SID>ZipBrowseSelect()<cr>
let &report= repkeep
" call Dret("zip#Browse")
endfun
" ---------------------------------------------------------------------
" ZipBrowseSelect: {{{2
fun! s:ZipBrowseSelect()
" call Dfunc("ZipBrowseSelect() zipfile<".b:zipfile."> curfile<".expand("%").">")
let repkeep= &report
set report=10
let fname= getline(".")
" sanity check
if fname =~ '^"'
let &report= repkeep
" call Dret("ZipBrowseSelect")
return
endif
if fname =~ '/$'
redraw!
echohl Error | echo "***error*** (zip#Browse) Please specify a file, not a directory" | echohl None
" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
let &report= repkeep
" call Dret("ZipBrowseSelect")
return
endif
" call Decho("fname<".fname.">")
" get zipfile to the new-window
let zipfile = b:zipfile
let curfile= expand("%")
" call Decho("zipfile<".zipfile.">")
" call Decho("curfile<".curfile.">")
new
if !exists("g:zip_nomax") || g:zip_nomax == 0
wincmd _
endif
let s:zipfile_{winnr()}= curfile
" call Decho("exe e ".fnameescape("zipfile:".zipfile.'::'.fname))
exe "e ".fnameescape("zipfile:".zipfile.'::'.fname)
filetype detect
let &report= repkeep
" call Dret("ZipBrowseSelect : s:zipfile_".winnr()."<".s:zipfile_{winnr()}.">")
endfun
" ---------------------------------------------------------------------
" zip#Read: {{{2
fun! zip#Read(fname,mode)
" call Dfunc("zip#Read(fname<".a:fname.">,mode=".a:mode.")")
let repkeep= &report
set report=10
if has("unix")
let zipfile = substitute(a:fname,'zipfile:\(.\{-}\)::[^\\].*$','\1','')
let fname = substitute(a:fname,'zipfile:.\{-}::\([^\\].*\)$','\1','')
else
let zipfile = substitute(a:fname,'^.\{-}zipfile:\(.\{-}\)::[^\\].*$','\1','')
let fname = substitute(a:fname,'^.\{-}zipfile:.\{-}::\([^\\].*\)$','\1','')
let fname = substitute(fname, '[', '[[]', 'g')
endif
" call Decho("zipfile<".zipfile.">")
" call Decho("fname <".fname.">")
" call Decho("exe r! ".g:zip_unzipcmd." -p -- ".s:Escape(zipfile,1)." ".s:Escape(fname,1))
exe "silent r! ".g:zip_unzipcmd." -p -- ".s:Escape(zipfile,1)." ".s:Escape(fname,1)
" cleanup
0d
set nomod
let &report= repkeep
" call Dret("zip#Read")
endfun
" ---------------------------------------------------------------------
" zip#Write: {{{2
fun! zip#Write(fname)
" call Dfunc("zip#Write(fname<".a:fname.">) zipfile_".winnr()."<".s:zipfile_{winnr()}.">")
let repkeep= &report
set report=10
" sanity checks
if !executable(g:zip_zipcmd)
redraw!
echohl Error | echo "***error*** (zip#Write) sorry, your system doesn't appear to have the zip pgm" | echohl None
" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
let &report= repkeep
" call Dret("zip#Write")
return
endif
if !exists("*mkdir")
redraw!
echohl Error | echo "***error*** (zip#Write) sorry, mkdir() doesn't work on your system" | echohl None
" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
let &report= repkeep
" call Dret("zip#Write")
return
endif
let curdir= getcwd()
let tmpdir= tempname()
" call Decho("orig tempname<".tmpdir.">")
if tmpdir =~ '\.'
let tmpdir= substitute(tmpdir,'\.[^.]*$','','e')
endif
" call Decho("tmpdir<".tmpdir.">")
call mkdir(tmpdir,"p")
" attempt to change to the indicated directory
if s:ChgDir(tmpdir,s:ERROR,"(zip#Write) cannot cd to temporary directory")
let &report= repkeep
" call Dret("zip#Write")
return
endif
" call Decho("current directory now: ".getcwd())
" place temporary files under .../_ZIPVIM_/
if isdirectory("_ZIPVIM_")
call s:Rmdir("_ZIPVIM_")
endif
call mkdir("_ZIPVIM_")
cd _ZIPVIM_
" call Decho("current directory now: ".getcwd())
if has("unix")
let zipfile = substitute(a:fname,'zipfile:\(.\{-}\)::[^\\].*$','\1','')
let fname = substitute(a:fname,'zipfile:.\{-}::\([^\\].*\)$','\1','')
else
let zipfile = substitute(a:fname,'^.\{-}zipfile:\(.\{-}\)::[^\\].*$','\1','')
let fname = substitute(a:fname,'^.\{-}zipfile:.\{-}::\([^\\].*\)$','\1','')
endif
" call Decho("zipfile<".zipfile.">")
" call Decho("fname <".fname.">")
if fname =~ '/'
let dirpath = substitute(fname,'/[^/]\+$','','e')
if executable("cygpath")
let dirpath = substitute(system("cygpath ".s:Escape(dirpath,0)),'\n','','e')
endif
" call Decho("mkdir(dirpath<".dirpath.">,p)")
call mkdir(dirpath,"p")
endif
if zipfile !~ '/'
let zipfile= curdir.'/'.zipfile
endif
" call Decho("zipfile<".zipfile."> fname<".fname.">")
exe "w! ".fnameescape(fname)
if executable("cygpath")
let zipfile = substitute(system("cygpath ".s:Escape(zipfile,0)),'\n','','e')
endif
if (has("win32") || has("win95") || has("win64") || has("win16")) && &shell !~? 'sh$'
let fname = substitute(fname, '[', '[[]', 'g')
endif
" call Decho(g:zip_zipcmd." -u ".s:Escape(fnamemodify(zipfile,":p"),0)." ".s:Escape(fname,0))
call system(g:zip_zipcmd." -u ".s:Escape(fnamemodify(zipfile,":p"),0)." ".s:Escape(fname,0))
if v:shell_error != 0
redraw!
echohl Error | echo "***error*** (zip#Write) sorry, unable to update ".zipfile." with ".fname | echohl None
" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
elseif s:zipfile_{winnr()} =~ '^\a\+://'
" support writing zipfiles across a network
let netzipfile= s:zipfile_{winnr()}
" call Decho("handle writing <".zipfile."> across network as <".netzipfile.">")
1split|enew
let binkeep= &binary
let eikeep = &ei
set binary ei=all
exe "e! ".fnameescape(zipfile)
call netrw#NetWrite(netzipfile)
let &ei = eikeep
let &binary = binkeep
q!
unlet s:zipfile_{winnr()}
endif
" cleanup and restore current directory
cd ..
call s:Rmdir("_ZIPVIM_")
call s:ChgDir(curdir,s:WARNING,"(zip#Write) unable to return to ".curdir."!")
call s:Rmdir(tmpdir)
setlocal nomod
let &report= repkeep
" call Dret("zip#Write")
endfun
" ---------------------------------------------------------------------
" s:Escape: {{{2
fun! s:Escape(fname,isfilt)
" call Dfunc("QuoteFileDir(fname<".a:fname."> isfilt=".a:isfilt.")")
if exists("*shellescape")
if a:isfilt
let qnameq= shellescape(a:fname,1)
else
let qnameq= shellescape(a:fname)
endif
else
let qnameq= g:zip_shq.escape(a:fname,g:zip_shq).g:zip_shq
endif
" call Dret("QuoteFileDir <".qnameq.">")
return qnameq
endfun
" ---------------------------------------------------------------------
" ChgDir: {{{2
fun! s:ChgDir(newdir,errlvl,errmsg)
" call Dfunc("ChgDir(newdir<".a:newdir."> errlvl=".a:errlvl." errmsg<".a:errmsg.">)")
try
exe "cd ".fnameescape(a:newdir)
catch /^Vim\%((\a\+)\)\=:E344/
redraw!
if a:errlvl == s:NOTE
echo "***note*** ".a:errmsg
elseif a:errlvl == s:WARNING
echohl WarningMsg | echo "***warning*** ".a:errmsg | echohl NONE
elseif a:errlvl == s:ERROR
echohl Error | echo "***error*** ".a:errmsg | echohl NONE
endif
" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
" call Dret("ChgDir 1")
return 1
endtry
" call Dret("ChgDir 0")
return 0
endfun
" ---------------------------------------------------------------------
" s:Rmdir: {{{2
fun! s:Rmdir(fname)
" call Dfunc("Rmdir(fname<".a:fname.">)")
if (has("win32") || has("win95") || has("win64") || has("win16")) && &shell !~? 'sh$'
call system("rmdir /S/Q ".s:Escape(a:fname,0))
else
call system("/bin/rm -rf ".s:Escape(a:fname,0))
endif
" call Dret("Rmdir")
endfun
" ------------------------------------------------------------------------
" Modelines And Restoration: {{{1
let &cpo= s:keepcpo
unlet s:keepcpo
" vim:ts=8 fdm=marker