updated for version 7.0117
diff --git a/runtime/plugin/NetrwFileHandlers.vim b/runtime/plugin/NetrwFileHandlers.vim
index 35df6dd..9c579e8 100644
--- a/runtime/plugin/NetrwFileHandlers.vim
+++ b/runtime/plugin/NetrwFileHandlers.vim
@@ -1,13 +1,13 @@
" NetrwFileHandlers: contains various extension-based file handlers for
" netrw's browsers' x command ("eXecute launcher")
-" Author: Charles E. Campbell, Jr.
-" Date: Aug 31, 2004
-" Version: 3
+" Author: Charles E. Campbell, Jr.
+" Date: Aug 31, 2004
+" Version: 3
" ---------------------------------------------------------------------
" Prevent Reloading: {{{1
if exists("g:loaded_netrwfilehandlers") || &cp
- finish
+ finish
endif
let g:loaded_netrwfilehandlers= "v3"
@@ -15,22 +15,16 @@
" NetrwFileHandler_html: handles html when the user hits "x" when the {{{1
" cursor is atop a *.html file
fun! NetrwFileHandler_html(pagefile)
-" call Dfunc("NetrwFileHandler_html(".a:pagefile.")")
-
- let page= substitute(a:pagefile,'^','file://','')
+ let page = substitute(a:pagefile, '^', 'file://', '')
if executable("mozilla")
-" call Decho("executing !mozilla ".page)
- exe "!mozilla \"".page.'"'
+ exe "!mozilla \"" . page . '"'
elseif executable("netscape")
-" call Decho("executing !netscape ".page)
- exe "!netscape \"".page.'"'
+ exe "!netscape \"" . page . '"'
else
-" call Dret("NetrwFileHandler_html 0")
- return 0
+ return 0
endif
-" call Dret("NetrwFileHandler_html 1")
return 1
endfun
@@ -38,240 +32,192 @@
" NetrwFileHandler_htm: handles html when the user hits "x" when the {{{1
" cursor is atop a *.htm file
fun! NetrwFileHandler_htm(pagefile)
-" call Dfunc("NetrwFileHandler_htm(".a:pagefile.")")
-
- let page= substitute(a:pagefile,'^','file://','')
+ let page = substitute(a:pagefile, '^', 'file://', '')
if executable("mozilla")
-" call Decho("executing !mozilla ".page)
- exe "!mozilla \"".page.'"'
+ exe "!mozilla \"" . page . '"'
elseif executable("netscape")
-" call Decho("executing !netscape ".page)
- exe "!netscape \"".page.'"'
+ exe "!netscape \"" . page . '"'
else
-" call Dret("NetrwFileHandler_htm 0")
- return 0
+ return 0
endif
-" call Dret("NetrwFileHandler_htm 1")
return 1
endfun
" ---------------------------------------------------------------------
" NetrwFileHandler_jpg: {{{1
fun! NetrwFileHandler_jpg(jpgfile)
-" call Dfunc("NetrwFileHandler_jpg(jpgfile<".a:jpgfile.">)")
-
if executable("gimp")
- exe "silent! !gimp -s ".a:jpgfile
+ exe "silent! !gimp -s " . a:jpgfile
elseif executable(expand("$SystemRoot")."/SYSTEM32/MSPAINT.EXE")
-" call Decho("silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT ".escape(a:jpgfile," []|'"))
- exe "!".expand("$SystemRoot")."/SYSTEM32/MSPAINT \"".a:jpgfile.'"'
+ exe "!" . expand("$SystemRoot") . "/SYSTEM32/MSPAINT \"" . a:jpgfile . '"'
else
-" call Dret("NetrwFileHandler_jpg 0")
- return 0
+ return 0
endif
-" call Dret("NetrwFileHandler_jpg 1")
return 1
endfun
" ---------------------------------------------------------------------
" NetrwFileHandler_gif: {{{1
fun! NetrwFileHandler_gif(giffile)
-" call Dfunc("NetrwFileHandler_gif(giffile<".a:giffile.">)")
-
if executable("gimp")
- exe "silent! !gimp -s ".a:giffile
- elseif executable(expand("$SystemRoot")."/SYSTEM32/MSPAINT.EXE")
- exe "silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT \"".a:giffile.'"'
+ exe "silent! !gimp -s " . a:giffile
+ elseif executable(expand("$SystemRoot") . "/SYSTEM32/MSPAINT.EXE")
+ exe "silent! !" . expand("$SystemRoot") . "/SYSTEM32/MSPAINT \"" . a:giffile . '"'
else
-" call Dret("NetrwFileHandler_gif 0")
return 0
endif
-" call Dret("NetrwFileHandler_gif 1")
return 1
endfun
" ---------------------------------------------------------------------
" NetrwFileHandler_png: {{{1
fun! NetrwFileHandler_png(pngfile)
-" call Dfunc("NetrwFileHandler_png(pngfile<".a:pngfile.">)")
-
if executable("gimp")
- exe "silent! !gimp -s ".a:pngfile
- elseif executable(expand("$SystemRoot")."/SYSTEM32/MSPAINT.EXE")
- exe "silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT \"".a:pngfile.'"'
+ exe "silent! !gimp -s " . a:pngfile
+ elseif executable(expand("$SystemRoot") . "/SYSTEM32/MSPAINT.EXE")
+ exe "silent! !" . expand("$SystemRoot") . "/SYSTEM32/MSPAINT \"" . a:pngfile . '"'
else
-" call Dret("NetrwFileHandler_png 0")
return 0
endif
-" call Dret("NetrwFileHandler_png 1")
return 1
endfun
" ---------------------------------------------------------------------
" NetrwFileHandler_pnm: {{{1
fun! NetrwFileHandler_pnm(pnmfile)
-" call Dfunc("NetrwFileHandler_pnm(pnmfile<".a:pnmfile.">)")
-
if executable("gimp")
- exe "silent! !gimp -s ".a:pnmfile
- elseif executable(expand("$SystemRoot")."/SYSTEM32/MSPAINT.EXE")
- exe "silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT \"".a:pnmfile.'"'
+ exe "silent! !gimp -s " . a:pnmfile
+ elseif executable(expand("$SystemRoot") . "/SYSTEM32/MSPAINT.EXE")
+ exe "silent! !" . expand("$SystemRoot") . "/SYSTEM32/MSPAINT \"" . a:pnmfile . '"'
else
-" call Dret("NetrwFileHandler_pnm 0")
return 0
endif
-" call Dret("NetrwFileHandler_pnm 1")
return 1
endfun
" ---------------------------------------------------------------------
" NetrwFileHandler_bmp: visualize bmp files {{{1
fun! NetrwFileHandler_bmp(bmpfile)
-" call Dfunc("NetrwFileHandler_bmp(bmpfile<".a:bmpfile.">)")
-
if executable("gimp")
- exe "silent! !gimp -s ".a:bmpfile
+ exe "silent! !gimp -s " . a:bmpfile
elseif executable(expand("$SystemRoot")."/SYSTEM32/MSPAINT.EXE")
- exe "silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT \"".a:bmpfile.'"'
+ exe "silent! !" . expand("$SystemRoot") . "/SYSTEM32/MSPAINT \"" . a:bmpfile . '"'
else
-" call Dret("NetrwFileHandler_bmp 0")
return 0
endif
-" call Dret("NetrwFileHandler_bmp 1")
return 1
endfun
" ---------------------------------------------------------------------
" NetrwFileHandler_pdf: visualize pdf files {{{1
fun! NetrwFileHandler_pdf(pdf)
-" " call Dfunc("NetrwFileHandler_pdf(pdf<".a:pdf.">)")
- if executable("gs")
- exe 'silent! !gs "'.a:pdf.'"'
+ if executable("acroread")
+ exe 'silent! !acroread "' . a:pdf . '"'
+ elseif executable("gs")
+ exe 'silent! !gs "' . a:pdf . '"'
else
-" " call Dret("NetrwFileHandler_pdf 0")
return 0
endif
-" " call Dret("NetrwFileHandler_pdf 1")
return 1
endfun
" ---------------------------------------------------------------------
" NetrwFileHandler_sxw: visualize sxw files {{{1
fun! NetrwFileHandler_sxw(sxw)
-" " call Dfunc("NetrwFileHandler_sxw(sxw<".a:sxw.">)")
if executable("gs")
- exe 'silent! !gs "'.a:sxw.'"'
+ exe 'silent! !gs "' . a:sxw . '"'
else
-" " call Dret("NetrwFileHandler_sxw 0")
return 0
endif
-" " call Dret("NetrwFileHandler_sxw 1")
return 1
endfun
" ---------------------------------------------------------------------
" NetrwFileHandler_doc: visualize doc files {{{1
fun! NetrwFileHandler_doc(doc)
-" " call Dfunc("NetrwFileHandler_doc(doc<".a:doc.">)")
-
if executable("oowriter")
- exe 'silent! !oowriter "'.a:doc.'"'
+ exe 'silent! !oowriter "' . a:doc . '"'
redraw!
else
-" " call Dret("NetrwFileHandler_doc 0")
return 0
endif
-" " call Dret("NetrwFileHandler_doc 1")
return 1
endfun
" ---------------------------------------------------------------------
" NetrwFileHandler_sxw: visualize sxw files {{{1
fun! NetrwFileHandler_sxw(sxw)
-" " call Dfunc("NetrwFileHandler_sxw(sxw<".a:sxw.">)")
-
if executable("oowriter")
- exe 'silent! !oowriter "'.a:sxw.'"'
+ exe 'silent! !oowriter "' . a:sxw . '"'
redraw!
else
-" " call Dret("NetrwFileHandler_sxw 0")
return 0
endif
-" " call Dret("NetrwFileHandler_sxw 1")
return 1
endfun
" ---------------------------------------------------------------------
" NetrwFileHandler_xls: visualize xls files {{{1
fun! NetrwFileHandler_xls(xls)
-" " call Dfunc("NetrwFileHandler_xls(xls<".a:xls.">)")
-
if executable("oocalc")
- exe 'silent! !oocalc "'.a:xls.'"'
+ exe 'silent! !oocalc "' . a:xls . '"'
redraw!
else
-" " call Dret("NetrwFileHandler_xls 0")
return 0
endif
-" " call Dret("NetrwFileHandler_xls 1")
return 1
endfun
" ---------------------------------------------------------------------
" NetrwFileHandler_ps: handles PostScript files {{{1
fun! NetrwFileHandler_ps(ps)
-" call Dfunc("NetrwFileHandler_ps()")
if executable("gs")
- exe "silent! !gs ".a:ps
+ exe "silent! !gs " . a:ps
redraw!
elseif executable("ghostscript")
- exe "silent! !ghostscript ".a:ps
+ exe "silent! !ghostscript " . a:ps
redraw!
elseif executable("ghostscript")
- exe "silent! !ghostscript ".a:ps
+ exe "silent! !ghostscript " . a:ps
redraw!
elseif executable("gswin32")
- exe "silent! !gswin32 \"".a:ps.'"'
+ exe "silent! !gswin32 \"" . a:ps . '"'
redraw!
else
-" call Dret("NetrwFileHandler_ps 0")
return 0
endif
-" call Dret("NetrwFileHandler_ps 1")
return 1
endfun
" ---------------------------------------------------------------------
" NetrwFileHandler_eps: handles encapsulated PostScript files {{{1
fun! NetrwFileHandler_eps(eps)
-" call Dfunc("NetrwFileHandler_ps()")
if executable("gs")
- exe "silent! !gs ".a:eps
+ exe "silent! !gs " . a:eps
redraw!
elseif executable("ghostscript")
- exe "silent! !ghostscript ".a:eps
+ exe "silent! !ghostscript " . a:eps
redraw!
elseif executable("ghostscript")
- exe "silent! !ghostscript ".a:eps
+ exe "silent! !ghostscript " . a:eps
redraw!
elseif executable("gswin32")
- exe "silent! !gswin32 \"".a:eps.'"'
+ exe "silent! !gswin32 \"" . a:eps . '"'
redraw!
else
-" call Dret("NetrwFileHandler_ps 0")
return 0
endif
endfun
@@ -279,35 +225,29 @@
" ---------------------------------------------------------------------
" NetrwFileHandler_fig: handles xfig files {{{1
fun! NetrwFileHandler_fig(fig)
-" call Dfunc("NetrwFileHandler_fig()")
if executable("xfig")
- exe "silent! !xfig ".a:fig
+ exe "silent! !xfig " . a:fig
redraw!
else
-" call Dret("NetrwFileHandler_fig 0")
return 0
endif
-" call Dret("NetrwFileHandler_fig 1")
return 1
endfun
" ---------------------------------------------------------------------
" NetrwFileHandler_obj: handles tgif's obj files {{{1
fun! NetrwFileHandler_obj(obj)
-" call Dfunc("NetrwFileHandler_obj()")
if has("unix") && executable("tgif")
- exe "silent! !tgif ".a:obj
+ exe "silent! !tgif " . a:obj
redraw!
else
-" call Dret("NetrwFileHandler_obj 0")
return 0
endif
-" call Dret("NetrwFileHandler_obj 1")
return 1
endfun
" ---------------------------------------------------------------------
-" vim: ts=4 fdm=marker
+" vim: fdm=marker
diff --git a/runtime/plugin/gzip.vim b/runtime/plugin/gzip.vim
index 0eebc5c..6560238 100644
--- a/runtime/plugin/gzip.vim
+++ b/runtime/plugin/gzip.vim
@@ -1,6 +1,6 @@
" Vim plugin for editing compressed files.
" Maintainer: Bram Moolenaar <Bram@vim.org>
-" Last Change: 2005 May 18
+" Last Change: 2005 Jul 26
" Exit quickly when:
" - this plugin was already loaded
@@ -15,188 +15,22 @@
" Remove all gzip autocommands
au!
- " Enable editing of gzipped files
- " set binary mode before reading the file
- " use "gzip -d", gunzip isn't always available
+ " 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 s:read("gzip -dn")
- autocmd BufReadPost,FileReadPost *.bz2 call s:read("bzip2 -d")
- autocmd BufReadPost,FileReadPost *.Z call s:read("uncompress")
- autocmd BufWritePost,FileWritePost *.gz call s:write("gzip")
- autocmd BufWritePost,FileWritePost *.bz2 call s:write("bzip2")
- autocmd BufWritePost,FileWritePost *.Z call s:write("compress -f")
- autocmd FileAppendPre *.gz call s:appre("gzip -dn")
- autocmd FileAppendPre *.bz2 call s:appre("bzip2 -d")
- autocmd FileAppendPre *.Z call s:appre("uncompress")
- autocmd FileAppendPost *.gz call s:write("gzip")
- autocmd FileAppendPost *.bz2 call s:write("bzip2")
- autocmd FileAppendPost *.Z call s:write("compress -f")
+ 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
-
-" Function to check that executing "cmd [-f]" works.
-" The result is cached in s:have_"cmd" for speed.
-fun s:check(cmd)
- let name = substitute(a:cmd, '\(\S*\).*', '\1', '')
- if !exists("s:have_" . name)
- let e = executable(name)
- if e < 0
- let r = system(name . " --version")
- let e = (r !~ "not found" && r != "")
- endif
- exe "let s:have_" . name . "=" . e
- endif
- exe "return s:have_" . name
-endfun
-
-" Set b:gzip_comp_arg to the gzip argument to be used for compression, based on
-" the flags in the compressed file.
-" The only compression methods that can be detected are max speed (-1) and max
-" compression (-9).
-fun s:set_compression(line)
- " get the Compression Method
- let l:cm = char2nr(a:line[2])
- " if it's 8 (DEFLATE), we can check for the compression level
- if l:cm == 8
- " get the eXtra FLags
- let l:xfl = char2nr(a:line[8])
- " max compression
- if l:xfl == 2
- let b:gzip_comp_arg = "-9"
- " min compression
- elseif l:xfl == 4
- let b:gzip_comp_arg = "-1"
- endif
- endif
-endfun
-
-
-" After reading compressed file: Uncompress text in buffer with "cmd"
-fun s:read(cmd)
- " don't do anything if the cmd is not supported
- if !s:check(a:cmd)
- return
- endif
-
- " for gzip check current compression level and set b:gzip_comp_arg.
- silent! unlet b:gzip_comp_arg
- if a:cmd[0] == 'g'
- call s:set_compression(getline(1))
- endif
-
- " make 'patchmode' empty, we don't want a copy of the written file
- let pm_save = &pm
- set pm=
- " remove 'a' and 'A' from 'cpo' to avoid the alternate file changes
- let cpo_save = &cpo
- set cpo-=a cpo-=A
- " set 'modifiable'
- let ma_save = &ma
- setlocal ma
- " when filtering the whole buffer, it will become empty
- let empty = line("'[") == 1 && line("']") == line("$")
- let tmp = tempname()
- let tmpe = tmp . "." . expand("<afile>:e")
- " write the just read lines to a temp file "'[,']w tmp.gz"
- execute "silent '[,']w " . tmpe
- " uncompress the temp file: call system("gzip -dn tmp.gz")
- call system(a:cmd . " " . tmpe)
- if !filereadable(tmp)
- " uncompress didn't work! Keep the compressed file then.
- echoerr "Error: Could not read uncompressed file"
- return
- endif
- " delete the compressed lines; remember the line number
- let l = line("'[") - 1
- if exists(":lockmarks")
- lockmarks '[,']d _
- else
- '[,']d _
- endif
- " read in the uncompressed lines "'[-1r tmp"
- setlocal nobin
- if exists(":lockmarks")
- execute "silent lockmarks " . l . "r " . tmp
- else
- execute "silent " . l . "r " . tmp
- endif
-
- " if buffer became empty, delete trailing blank line
- if empty
- silent $delete _
- 1
- endif
- " delete the temp file and the used buffers
- call delete(tmp)
- silent! exe "bwipe " . tmp
- silent! exe "bwipe " . tmpe
- let &pm = pm_save
- let &cpo = cpo_save
- let &l:ma = ma_save
- " When uncompressed the whole buffer, do autocommands
- if empty
- if &verbose >= 8
- execute "doau BufReadPost " . expand("%:r")
- else
- execute "silent! doau BufReadPost " . expand("%:r")
- endif
- endif
-endfun
-
-" After writing compressed file: Compress written file with "cmd"
-fun s:write(cmd)
- " don't do anything if the cmd is not supported
- if s:check(a:cmd)
- " Rename the file before compressing it.
- let nm = resolve(expand("<afile>"))
- let nmt = s:tempname(nm)
- if rename(nm, nmt) == 0
- if exists("b:gzip_comp_arg")
- call system(a:cmd . " " . b:gzip_comp_arg . " " . nmt)
- else
- call system(a:cmd . " " . nmt)
- endif
- call rename(nmt . "." . expand("<afile>:e"), nm)
- endif
- endif
-endfun
-
-" Before appending to compressed file: Uncompress file with "cmd"
-fun s:appre(cmd)
- " don't do anything if the cmd is not supported
- if s:check(a:cmd)
- let nm = expand("<afile>")
-
- " for gzip check current compression level and set b:gzip_comp_arg.
- silent! unlet b:gzip_comp_arg
- if a:cmd[0] == 'g'
- call s:set_compression(readfile(nm, "b", 1)[0])
- endif
-
- " Rename to a weird name to avoid the risk of overwriting another file
- let nmt = expand("<afile>:p:h") . "/X~=@l9q5"
- let nmte = nmt . "." . expand("<afile>:e")
- if rename(nm, nmte) == 0
- if &patchmode != "" && getfsize(nm . &patchmode) == -1
- " Create patchmode file by creating the decompressed file new
- call system(a:cmd . " -c " . nmte . " > " . nmt)
- call rename(nmte, nm . &patchmode)
- else
- call system(a:cmd . " " . nmte)
- endif
- call rename(nmt, nm)
- endif
- endif
-endfun
-
-" find a file name for the file to be compressed. Use "name" without an
-" extension if possible. Otherwise use a weird name to avoid overwriting an
-" existing file.
-fun s:tempname(name)
- let fn = fnamemodify(a:name, ":r")
- if !filereadable(fn) && !isdirectory(fn)
- return fn
- endif
- return fnamemodify(a:name, ":p:h") . "/X~=@l9q5"
-endfun
-
-" vim: set sw=2 :
diff --git a/runtime/plugin/tar.vim b/runtime/plugin/tar.vim
index 26fade4..cc97f44 100644
--- a/runtime/plugin/tar.vim
+++ b/runtime/plugin/tar.vim
@@ -1,185 +1,34 @@
-" vim:set ts=4 sw=4 ai nobackup:
-
-" tar.vim -- a vim plugin for browsing tarfiles
+" tar.vim -- a Vim plugin for browsing tarfiles
" Copyright (c) 2002, Michael C. Toren <mct@toren.net>
+" Distributed under the GNU General Public License.
+"
+" Version: 1.01
+" Last Change: 2005 Jul 26
"
" Updates are available from <http://michael.toren.net/code/>. If you
" find this script useful, or have suggestions for improvements, please
" let me know.
+" Also look there for further comments and documentation.
"
-" Usage:
-" Once this script is installed, attempting to edit a tarfile will present
-" the user with a list of files contained in the tar archive. By moving the
-" cursor over a filename and pressing ENTER, the contents of a file can be
-" viewed in read-only mode, in a new window. Unfortunately, write support
-" for tarfile components is not currently possible.
-"
-" Requirements:
-" GNU tar, or a tar implementation that supports the "P" (don't strip
-" out leading /'s from filenames), and "O" (extract files to standard
-" output) options. Additionally, gzip is required for handling *.tar.Z,
-" *.tar.gz, and *.tgz compressed tarfiles, and bzip2 is required for
-" handling *.tar.bz2 compressed tarfiles. A unix-like operating system
-" is probably also required.
-"
-" Installation:
-" Place this file, tar.vim, in your $HOME/.vim/plugin directory, and
-" either restart vim, or execute ":source $HOME/.vim/plugin/tar.vim"
-"
-" Todo:
-" - Handle zipfiles?
-" - Implement write support, somehow.
-"
-" License:
-" This program is free software; you can redistribute it and/or modify it
-" under the terms of the GNU General Public License, version 2, as published
-" by the Free Software Foundation.
-"
-" This program is distributed in the hope that it will be useful, but
-" WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-" or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-" for more details.
-"
-" A copy of the GNU GPL is available as /usr/doc/copyright/GPL on Debian
-" systems, or on the World Wide Web at http://www.gnu.org/copyleft/gpl.html
-" You can also obtain it by writing to the Free Software Foundation, Inc.,
-" 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
-"
-" Changelog:
-" Tue Dec 31 13:38:08 EST 2002 First release to beta testers
-" Sat Jan 4 14:06:19 EST 2003 Version 1.00 released
-
-let s:version = "1.00"
+" This part only sets the autocommands. The functions are in autoload/tar.vim.
if has("autocmd")
-augroup tar
- au!
- au BufReadCmd tarfile:* call s:TarRead(expand("<afile>"), 1)
- au BufReadCmd tarfile:*/* call s:TarRead(expand("<afile>"), 1)
- au FileReadCmd tarfile:* call s:TarRead(expand("<afile>"), 0)
- au FileReadCmd tarfile:*/* call s:TarRead(expand("<afile>"), 0)
+ augroup tar
+ au!
+ au BufReadCmd tarfile:* call tar#Read(expand("<afile>"), 1)
+ au BufReadCmd tarfile:*/* call tar#Read(expand("<afile>"), 1)
+ au FileReadCmd tarfile:* call tar#Read(expand("<afile>"), 0)
+ au FileReadCmd tarfile:*/* call tar#Read(expand("<afile>"), 0)
- au BufWriteCmd tarfile:* call s:TarWrite(expand("<afile>"))
- au BufWriteCmd tarfile:*/* call s:TarWrite(expand("<afile>"))
- au FileWriteCmd tarfile:* call s:TarWrite(expand("<afile>"))
- au FileWriteCmd tarfile:*/* call s:TarWrite(expand("<afile>"))
+ au BufWriteCmd tarfile:* call tar#Write(expand("<afile>"))
+ au BufWriteCmd tarfile:*/* call tar#Write(expand("<afile>"))
+ au FileWriteCmd tarfile:* call tar#Write(expand("<afile>"))
+ au FileWriteCmd tarfile:*/* call tar#Write(expand("<afile>"))
- au BufReadCmd *.tar call s:TarBrowse(expand("<afile>"))
- au BufReadCmd *.tar.gz call s:TarBrowse(expand("<afile>"))
- au BufReadCmd *.tar.bz2 call s:TarBrowse(expand("<afile>"))
- au BufReadCmd *.tar.Z call s:TarBrowse(expand("<afile>"))
- au BufReadCmd *.tgz call s:TarBrowse(expand("<afile>"))
-augroup END
+ au BufReadCmd *.tar call tar#Browse(expand("<afile>"))
+ au BufReadCmd *.tar.gz call tar#Browse(expand("<afile>"))
+ au BufReadCmd *.tar.bz2 call tar#Browse(expand("<afile>"))
+ au BufReadCmd *.tar.Z call tar#Browse(expand("<afile>"))
+ au BufReadCmd *.tgz call tar#Browse(expand("<afile>"))
+ augroup END
endif
-
-function! s:TarWrite(argument)
- echo "ERROR: Sorry, no write support for tarfiles yet"
-endfunction
-
-function! s:TarRead(argument, cleanup)
- let l:argument = a:argument
- let l:argument = substitute(l:argument, '^tarfile:', '', '')
- let l:argument = substitute(l:argument, '^\~', $HOME, '')
-
- let l:tarfile = l:argument
- while 1
- if (l:tarfile == "" || l:tarfile == "/")
- echo "ERROR: Could not find a readable tarfile in path:" l:argument
- return
- endif
-
- if filereadable(l:tarfile) " found it!
- break
- endif
-
- let l:tarfile = fnamemodify(l:tarfile, ":h")
- endwhile
-
- let l:toextract = strpart(l:argument, strlen(l:tarfile) + 1)
-
- if (l:toextract == "")
- return
- endif
-
- let l:cat = s:TarCatCommand(l:tarfile)
- execute "r !" . l:cat . " < '" . l:tarfile . "'"
- \ " | tar OPxf - '" . l:toextract . "'"
-
- if (a:cleanup)
- 0d "blank line
- execute "doautocmd BufReadPost " . expand("%")
- setlocal readonly
- silent preserve
- endif
-endfunction
-
-function! s:TarBrowse(tarfile)
- setlocal noswapfile
- setlocal buftype=nofile
- setlocal bufhidden=hide
- setlocal filetype=
- setlocal nobuflisted
- setlocal buftype=nofile
- setlocal wrap
-
- let l:tarfile = a:tarfile
- let b:tarfile = l:tarfile
- let l:cat = s:TarCatCommand(l:tarfile)
-
- if ! filereadable(l:tarfile)
- let l:tarfile = substitute(l:tarfile, '^tarfile:', '', '')
- endif
-
- if ! filereadable(l:tarfile)
- echo "ERROR: File not readable:" l:tarfile
- return
- endif
-
- call s:Say("\" tar.vim version " . s:version)
- call s:Say("\" Browsing tarfile " . l:tarfile)
- call s:Say("\" Hit ENTER to view contents in new window")
- call s:Say("")
-
- silent execute "r!" . l:cat . "<'" . l:tarfile . "'| tar Ptf - "
- 0d "blank line
- /^$/1
-
- setlocal readonly
- setlocal nomodifiable
- noremap <silent> <buffer> <cr> :call <SID>TarBrowseSelect()<cr>
-endfunction
-
-function! s:TarBrowseSelect()
- let l:line = getline(".")
-
- if (l:line =~ '^" ')
- return
- endif
-
- if (l:line =~ '/$')
- echo "Please specify a file, not a directory"
- return
- endif
-
- let l:selection = "tarfile:" . b:tarfile . "/" . l:line
- new
- wincmd _
- execute "e " . l:selection
-endfunction
-
-" kludge to deal with compressed archives
-function! s:TarCatCommand(tarfile)
- if a:tarfile =~# '\.\(gz\|tgz\|Z\)$'
- let l:cat = "gzip -d -c"
- elseif a:tarfile =~# '\.bz2$'
- let l:cat = "bzip2 -d -c"
- else
- let l:cat = "cat"
- endif
- return l:cat
-endfunction
-
-function! s:Say(string)
- let @" = a:string
- $ put
-endfunction