Kevin Goodsell wrote:
> Opening a zip file with Vim doesn't work properly if the zip file
> includes a comment. For example, create a zip file this way:
> $ touch foo.txt
> $ zip -z foo.zip foo.txt
> adding: foo.txt (stored 0%)
> enter new zip file comment (end with .):
> When opening this zip, the file list will be displayed differently,
> and opening a file will fail with the cryptic error "caution: filename
> not matched".
> The problem comes from the zip#Browse() function in autoload/zip.vim.
> Once the zip contents have been listed with "unzip -l --
> archive-name", It does the following:
> let namecol= stridx(getline(6),'Name') + 1
> Note that it expects to find 'Name' (the column header for the zip
> listing) on line six. This works fine if there is no comment, because
> the listing begins on line five of the buffer and the headers appear
> on the second line of the listing. However, when a comment is present
> unzip -l includes the comment before the headers, and the headers will
> instead be on some line after line six. This causes the lines of the
> listing to be left as-is, with file size and time information, rather
> than being stripped down to just the name. When one of these lines is
> selected, it is assumed that the length and time are part of the name,
> but no file with that name can be located in the zip.
> Here is a possible patch. I tried to simplify things a bit, using :d
> with line numbers instead of :g with pattens. I also left the cursor
> at the first file in the list, which seems nicer to me. This would
> clearly not work with a localized version of zip that used non-English
> names for the headers, but then neither does the original version.
> This is based on a slightly older version of zip.vim, but there are no
> relevant changes in the current version. The patch should apply
> --- /usr/share/vim/vim72/autoload/zip.vim 2009-09-21 04:22:52.000000000 -0700
> +++ zip.vim 2010-12-23 17:37:00.000000000 -0800
> @@ -121,14 +121,15 @@
> " call Decho("line 6: ".getline(6))
> - let namecol= stridx(getline(6),'Name') + 1
> + 1
> + let [headerline, namecol] =
> " call Decho("namecol=".namecol)
> - 4,$g/^\s*----/d
> - 4,$g/^\s*\a/d
> - $d
> + exec printf("5,%dd", headerline+1)
> + $-1,$d
> if namecol> 0
> exe 'silent 4,$s/^.*\%'.namecol.'c//'
> + 5
> setlocal noma nomod ro
> noremap<silent> <buffer> <cr> :call<SID>ZipBrowseSelect()<cr>
I realize that this report is over a year old; I'm going through my old
email and saw this.
Perhaps the most recent zip.vim already handles this? Please try v25 of
OTOH, its quite possible that I've already discussed this with you back
when but didn't take your email off the hasn't-handled list.
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php