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

Re: vim7: significant vi incompatibility

Expand Messages
  • Walter Briscoe
    In message of Mon, 6 Jun 2005 17:15:52 in , Bram Moolenaar writes ... I had a vim whose
    Message 1 of 8 , Jun 6, 2005
    • 0 Attachment
      In message <200506061515.j56FFqIu014601@...> of Mon, 6 Jun
      2005 17:15:52 in , Bram Moolenaar <Bram@...> writes
      >
      >Walter Briscoe wrote:
      >
      >> I came on this in todo.txt:
      >> ...
      >> Vi incompatibility:
      >> 9 In Ex mode, "u" undoes all changes, not just the last one. (John Cowan)
      >> ...
      >>
      >> I tried to check if it is true.
      >> Why does this seize: %VIM%\vim70aa\vim.exe -u NONE -e -s t.vim t.t ?
      >> This does seize too: %VIM%\vim70aa\vim.exe -u NONE -e t.t < t.vim
      >> given t.vim is:
      >> :a
      >> hello
      >> .
      >> :a
      >> world
      >> .
      >> :u
      >> :wq
      >>
      >> Without -e, the -s line does not seize.
      >> :help -s has "Only works when not started in Ex mode.
      >> The failure mode seems a bit heavy.
      >>
      >> OTOH, when I did :so t.vim in an empty t.t created by
      >> %VIM%\vim70aa\vim.exe -u NONE t.t, I found "world" was written to t.t
      >> as expected.
      >> If I used, :x in place of :wq, t.t was not created which looks like the
      >> failure John Cowan reported.
      >>
      >> I get similar behaviors when I do %VIM%\vim70aa\vim.exe -u NONE -e t.t
      >> and enter "so t.vim".
      >>
      >> What is the original scenario?
      >> I will look at making behavior consistent but would prefer to start from
      >> the pointed alluded to by todo.txt.
      >
      >This problem has already been fixed in Vim 7. In Vim 6.3 you can
      >reproduce it with:
      >
      > vim -e -u NONE
      > 0a
      > this is line 1
      > this is line 2
      > .
      > 1
      > s/this/THIS/p
      > s/line/LINE/p
      > u
      >
      >You end up without any text.
      >
      >The next todo item about "1p" failing has also been done, I'll remove
      >it.
      >

      I had a vim whose sources were about 10 days old when I tested.
      I now have a vim which was refreshed on Sunday, 2005-06-05.
      I agree the scenario you describe is US in vim6.3 and OK in vim7.

      The difference I found between :x and :wq remains.
      I would appreciate confirmation that this is a bug.

      I shall use a debugger to look at what happens.
      --
      Walter Briscoe
    • Bram Moolenaar
      ... :x only writes when there is a change, :wq always writes. -- Latest survey shows that 3 out of 4 people make up 75% of the world s population. /// Bram
      Message 2 of 8 , Jun 7, 2005
      • 0 Attachment
        Walter Briscoe wrote:

        > The difference I found between :x and :wq remains.
        > I would appreciate confirmation that this is a bug.

        ":x" only writes when there is a change, ":wq" always writes.

        --
        Latest survey shows that 3 out of 4 people make up 75% of the
        world's population.

        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
        /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
        \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
        \\\ Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html ///
      • Walter Briscoe
        In message of Tue, 7 Jun 2005 16:51:41 in , Bram Moolenaar writes ... I understand that. I
        Message 3 of 8 , Jun 7, 2005
        • 0 Attachment
          In message <200506071451.j57Epfnh041764@...> of Tue, 7 Jun
          2005 16:51:41 in , Bram Moolenaar <Bram@...> writes
          >
          >Walter Briscoe wrote:
          >
          >> The difference I found between :x and :wq remains.
          >> I would appreciate confirmation that this is a bug.
          >
          >":x" only writes when there is a change, ":wq" always writes.
          >

          I understand that.

          I have a scenario where there is a change but vim does not recognise it.
          I have another where there is no change but should be.

          Given t0.vim consists of:
          :a
          hello
          .
          :a
          world
          .
          :u

          and t.t does not exist, I do %VIM%\vim70aa\vim.exe -u NONE t.t
          and therein do :so t0.vim.
          The buffer contains the line "hello" but is not considered changed.
          :x closes vim but does not create t.t.

          If t.t starts consisting of the line "original" and I do the same thing,
          no change is (wrongly) made to the buffer.
          The :u command undoes both :a commands.

          I shall continue to look at the code for explanation.
          --
          Walter Briscoe
        • Bram Moolenaar
          ... I can reproduce the problem. I ll look into it. -- George: I just got a new set of golf clubs for my wife! John: Great trade! /// Bram Moolenaar --
          Message 4 of 8 , Jun 8, 2005
          • 0 Attachment
            Walter Briscoe wrote:

            > I have a scenario where there is a change but vim does not recognise it.
            > I have another where there is no change but should be.
            >
            > Given t0.vim consists of:
            > :a
            > hello
            > .
            > :a
            > world
            > .
            > :u
            >
            > and t.t does not exist, I do %VIM%\vim70aa\vim.exe -u NONE t.t
            > and therein do :so t0.vim.
            > The buffer contains the line "hello" but is not considered changed.
            > :x closes vim but does not create t.t.
            >
            > If t.t starts consisting of the line "original" and I do the same thing,
            > no change is (wrongly) made to the buffer.
            > The :u command undoes both :a commands.
            >
            > I shall continue to look at the code for explanation.

            I can reproduce the problem. I'll look into it.

            --
            George: "I just got a new set of golf clubs for my wife!"
            John: "Great trade!"

            /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
            /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
            \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
            \\\ Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html ///
          • Bram Moolenaar
            ... +++ ex_cmds.c 8 Jun 2005 09:31:26 -0000 @@ -3605,7 +3605,8 @@ break; } if ((p[0] == . && p[1] == NUL) - || (!did_undo && u_save(lnum, lnum + 1) ==
            Message 5 of 8 , Jun 8, 2005
            • 0 Attachment
              Walter Briscoe wrote:

              > I have a scenario where there is a change but vim does not recognise it.
              > I have another where there is no change but should be.
              >
              > Given t0.vim consists of:
              > :a
              > hello
              > .
              > :a
              > world
              > .
              > :u
              >
              > and t.t does not exist, I do %VIM%\vim70aa\vim.exe -u NONE t.t
              > and therein do :so t0.vim.
              > The buffer contains the line "hello" but is not considered changed.
              > :x closes vim but does not create t.t.
              >
              > If t.t starts consisting of the line "original" and I do the same thing,
              > no change is (wrongly) made to the buffer.
              > The :u command undoes both :a commands.

              This patch should solve it:

              --- ex_cmds.c 7 Jun 2005 21:12:07 -0000 1.32
              +++ ex_cmds.c 8 Jun 2005 09:31:26 -0000
              @@ -3605,7 +3605,8 @@
              break;
              }
              if ((p[0] == '.' && p[1] == NUL)
              - || (!did_undo && u_save(lnum, lnum + 1) == FAIL))
              + || (!did_undo && u_save(lnum, lnum + 1 + (empty ? 1 : 0))
              + == FAIL))
              {
              vim_free(theline);
              break;


              The empty line that's deleted wasn't saved for undo.

              Note that undo undoes all commands in between typed commands. That
              might seem strange, but it's intentional. It makes it possible to undo
              the effect of a ":source script.vim".

              However, this is not exactly compatible with Ex (in Vi you can't source
              a script like this). I'll see if that can be fixed.

              --
              "Oh, no! NOT the Spanish Inquisition!"
              "NOBODY expects the Spanish Inquisition!!!"
              -- Monty Python sketch --
              "Oh, no! NOT another option!"
              "EVERYBODY expects another option!!!"
              -- Discussion in vim-dev mailing list --

              /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
              /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
              \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
              \\\ Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html ///
            • Walter Briscoe
              In message of Wed, 8 Jun 2005 11:45:53 in , Bram Moolenaar writes ... [snip] ... The behavior
              Message 6 of 8 , Jun 8, 2005
              • 0 Attachment
                In message <200506080945.j589jrWM084585@...> of Wed, 8 Jun
                2005 11:45:53 in , Bram Moolenaar <Bram@...> writes
                >
                >Walter Briscoe wrote:
                >
                >> I have a scenario where there is a change but vim does not recognise it.
                >> I have another where there is no change but should be.
                [snip]

                >This patch should solve it:

                The behavior is now consistent

                >Note that undo undoes all commands in between typed commands. That
                >might seem strange, but it's intentional. It makes it possible to undo
                >the effect of a ":source script.vim".

                I thought that was the intention.
                I see that there are good reasons for :so foo|u being a null operation.
                I am not sure that u in foo should have a similar effect.

                Is this documented enough?

                >
                >However, this is not exactly compatible with Ex (in Vi you can't source
                >a script like this). I'll see if that can be fixed.

                In ex, I think you can do ex t.t < t1.vim
                I tried that in Knoppix. :u cleared both changes.
                Then, `strings < /usr/bin/ex | grep -i vim` strongly suggested ex is an
                alias of vim 6.3. ;(
                --
                Walter Briscoe
              Your message has been successfully submitted and would be delivered to recipients shortly.