Loading ...
Sorry, an error occurred while loading the content.

Win32 gzip.vim always uses default fileformat

Expand Messages
  • Walter Briscoe
    This is a problem which has been irritating me for a while. I have not reported it before as it is cosmetic. I compress a UNIX file. I open the compressed
    Message 1 of 2 , Jul 1, 2003
    • 0 Attachment
      This is a problem which has been irritating me for a while.
      I have not reported it before as it is cosmetic.
      I compress a UNIX file. I open the compressed file. 'fileformat' is dos.

      This matters because Bram needs patches as a unix output from diff -c of
      a pair of unix files. I have a tendency to do something like
      :: foo.diff is a DOS file
      diff -c foo.0 foo > foo.diff
      :: Convert to unix
      vim -u NONE "+set ff=unix" foo.diff
      :: Squeeze
      gzip foo.diff.gz
      :: Inspect patch for plausibility
      vim foo.diff.gz
      :: It is confusing at this point to have vim tell me I have a dos file!

      I don't know enough about VIM scripting to fix this problem.

      I failed with
      --- 66,86 ----
      " when filtering the whole buffer, it will become empty
      let empty = line("'[") == 1 && line("']") == line("$")
      let tmp = tempname()
      ! let tmpe = tmp . "." . a:extn
      " write the just read lines to a temp file "'[,']w tmp.gz"
      execute "silent '[,']w " . tmpe
      " uncompress the temp file: call system("gzip -d tmp.gz")
      call system(a:cmd . " " . tmpe)
      ! " if buffer is being replaced, take a filetype-preserving shortcut
      if empty
      ! execute "silent e " . tmp
      ! else
      ! " delete the compressed lines; remember the line number
      ! let l = line("'[") - 1
      ! '[,']d
      ! " read in the uncompressed lines "'[-1r tmp"
      ! setlocal nobin
      ! execute "silent " . l . "r " . tmp
      endif
      " delete the temp file and the used buffers
      call delete(tmp)

      I did find another problem with ":help todo". It is:
      8 In the gzip plugin, also recognize *.gz.orig, *.gz.bak, etc. Like it's
      done for filetype detection.
      I decided to fix what was asked. I did not make the analogous change for
      .bz2.orig or .Z.orig. The change to do so is trivial and I expect Bram
      will pick that up if he accepts the work at all :-)

      More serious is a documentation "bug". I assume the report is new.
      As I have already suggested, I don't know much about Vim scripting.
      ":help file-pattern" returns
      *file-pattern*
      The pattern is interpreted like mostly used in file names:
      * matches any sequence of characters
      ? matches any single character
      \? matches a '?'
      . matches a '.'
      ~ matches a '~'
      , separates patterns
      \, matches a ','
      { } like \( \) in a |pattern|
      , inside { }: like \| in a |pattern|
      \ special meaning like in a |pattern|
      [ch] matches 'c' or 'h'

      I was pleasantly surprised after reading that to find that the following
      works: "*.gz.[^.]\{1,\}". I suppose I can interpolate from [ch] to [^.];
      the surprise was that "\{1,\}" was accepted.

      The patch follows. If it is opened with the gzip.vim plugin, ":set
      fileformat" will return the default format for the vim port rather than
      that for the document. The actual fileformat is unix but shows as dos on
      win32 and probably as mac on apples.
    • Bram Moolenaar
      ... We have been trying to fix this, but apparently it still doesn t work properly. Charles, can you reproduce this problem? ... Thanks. I ll add this to the
      Message 2 of 2 , Jul 1, 2003
      • 0 Attachment
        Walter Briscoe wrote:

        > This is a problem which has been irritating me for a while.
        > I have not reported it before as it is cosmetic.
        > I compress a UNIX file. I open the compressed file. 'fileformat' is dos.

        We have been trying to fix this, but apparently it still doesn't work
        properly.

        Charles, can you reproduce this problem?


        > I did find another problem with ":help todo". It is:
        > 8 In the gzip plugin, also recognize *.gz.orig, *.gz.bak, etc. Like it's
        > done for filetype detection.
        > I decided to fix what was asked. I did not make the analogous change for
        > .bz2.orig or .Z.orig. The change to do so is trivial and I expect Bram
        > will pick that up if he accepts the work at all :-)

        Thanks. I'll add this to the todo list.

        > More serious is a documentation "bug". I assume the report is new.
        > As I have already suggested, I don't know much about Vim scripting.
        > ":help file-pattern" returns
        > *file-pattern*
        > The pattern is interpreted like mostly used in file names:
        > * matches any sequence of characters
        > ? matches any single character
        > \? matches a '?'
        > . matches a '.'
        > ~ matches a '~'
        > , separates patterns
        > \, matches a ','
        > { } like \( \) in a |pattern|
        > , inside { }: like \| in a |pattern|
        > \ special meaning like in a |pattern|
        > [ch] matches 'c' or 'h'
        >
        > I was pleasantly surprised after reading that to find that the following
        > works: "*.gz.[^.]\{1,\}". I suppose I can interpolate from [ch] to [^.];
        > the surprise was that "\{1,\}" was accepted.

        It's this line that applies:

        \ special meaning like in a |pattern|

        --
        ARTHUR: Right! Knights! Forward!
        ARTHUR leads a charge toward the castle. Various shots of them battling on,
        despite being hit by a variety of farm animals.
        "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
        /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\
        \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
        \\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html ///
      Your message has been successfully submitted and would be delivered to recipients shortly.