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

Re: [patch] implement undo in :s_flags

Expand Messages
  • Christian Brabandt
    ... This works, although I would personally don t think this is very reasonable. :%s will not consider the newly added lines (it determines the range before
    Message 1 of 7 , Oct 1, 2012
    • 0 Attachment
      On Sun, September 30, 2012 15:41, Andy Wokula wrote:
      > Am 30.09.2012 14:42, schrieb Bram Moolenaar:
      >>
      >> Christian Brabandt wrote:
      >>
      >>> Bram,
      >>> attached patch implements undo when doing :s/.../.../gc
      >>>
      >>> This has been requested recently in
      >>> https://groups.google.com/group/vim_dev/msg/9930ef0f86421814
      >>>
      >>> And I think, I saw a request like this on the sf.net bug tracker, but I
      >>> can't find it right now. Additionally, I also added using Ctrl-L for
      >>> redrawing the screen as I found this useful.
      >>
      >> Yeah, this is useful. But also tricky, if the undo is done wrong then
      >> the text may get messed up. Can you think of situations where something
      >> could go wrong? And it would be nice to have tests for that.
      >
      > What about a replacement function that edits text?
      >
      >
      > com! InsaneSubst :%s/\w\+/\=InsaneEdit(submatch(0))/
      >
      > func! InsaneEdit(str)
      > $put = a:str
      > return '('. a:str. ')'
      > endfunc

      This works, although I would personally don't think this is very
      reasonable. :%s will not consider the newly added lines (it determines
      the range before starting the command) and I have seen strange effects
      when doing a replacement and the function changes the text directly
      (e.g. E315 ml_get: invalid lnum...)

      regards,
      Christian

      --
      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
    • Christian Brabandt
      ... Updated patch also works for undo in vi-compatible way and includes a test. The testing part was harder than expected, because vim doesn t sync undo, when
      Message 2 of 7 , Oct 8, 2012
      • 0 Attachment
        On Sun, September 30, 2012 14:42, Bram Moolenaar wrote:
        >> attached patch implements undo when doing :s/.../.../gc
        >
        > Yeah, this is useful. But also tricky, if the undo is done wrong then
        > the text may get messed up. Can you think of situations where something
        > could go wrong? And it would be nice to have tests for that.
        >

        Updated patch also works for undo in vi-compatible way and includes a
        test. The testing part was harder than expected, because vim doesn't
        sync undo, when reading from a script, so I explicitly sync undo
        when using :s/.../.../c and reading from a script.

        There is one limitation so: Vim only stores up to 256 places for where
        to start searching after an undo. If you have replaced more, Vim won't
        start at the correct column afterwards. I thought about using a garray_T
        for storing the column, but wasn't successful.

        regards,
        Christian.

        --
        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
      • Bram Moolenaar
        ... Thanks. I ll have a look at it later. -- (letter from Mark to Mike, about the film s probable certificate) For an A we would have to: Lose as many shits
        Message 3 of 7 , Oct 9, 2012
        • 0 Attachment
          Christian Brabandt wrote:

          > On Sun, September 30, 2012 14:42, Bram Moolenaar wrote:
          > >> attached patch implements undo when doing :s/.../.../gc
          > >
          > > Yeah, this is useful. But also tricky, if the undo is done wrong then
          > > the text may get messed up. Can you think of situations where somethin=
          > g
          > > could go wrong? And it would be nice to have tests for that.
          > >
          >
          > Updated patch also works for undo in vi-compatible way and includes a
          > test. The testing part was harder than expected, because vim doesn't
          > sync undo, when reading from a script, so I explicitly sync undo
          > when using :s/.../.../c and reading from a script.
          >
          > There is one limitation so: Vim only stores up to 256 places for where
          > to start searching after an undo. If you have replaced more, Vim won't
          > start at the correct column afterwards. I thought about using a garray_T
          > for storing the column, but wasn't successful.

          Thanks. I'll have a look at it later.

          --
          (letter from Mark to Mike, about the film's probable certificate)
          For an 'A' we would have to: Lose as many shits as possible; Take Jesus
          Christ out, if possible; Loose "I fart in your general direction"; Lose
          "the oral sex"; Lose "oh, fuck off"; Lose "We make castanets out of your
          testicles"
          "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

          /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
          /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
          \\\ an exciting new programming language -- http://www.Zimbu.org ///
          \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

          --
          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
        • justrajdeep
          ... This would be one great addition to vim if the patch gets accepted. -- -- You received this message from the vim_dev maillist. Do not top-post! Type your
          Message 4 of 7 , Jan 8
          • 0 Attachment
            On Tuesday, October 9, 2012 4:37:58 PM UTC+5:30, Bram Moolenaar wrote:
            > Christian Brabandt wrote:
            >
            > > On Sun, September 30, 2012 14:42, Bram Moolenaar wrote:
            > > >> attached patch implements undo when doing :s/.../.../gc
            > > >
            > > > Yeah, this is useful. But also tricky, if the undo is done wrong then
            > > > the text may get messed up. Can you think of situations where somethin=
            > > g
            > > > could go wrong? And it would be nice to have tests for that.
            > > >
            > >
            > > Updated patch also works for undo in vi-compatible way and includes a
            > > test. The testing part was harder than expected, because vim doesn't
            > > sync undo, when reading from a script, so I explicitly sync undo
            > > when using :s/.../.../c and reading from a script.
            > >
            > > There is one limitation so: Vim only stores up to 256 places for where
            > > to start searching after an undo. If you have replaced more, Vim won't
            > > start at the correct column afterwards. I thought about using a garray_T
            > > for storing the column, but wasn't successful.
            >
            > Thanks. I'll have a look at it later.
            >
            > --
            > (letter from Mark to Mike, about the film's probable certificate)
            > For an 'A' we would have to: Lose as many shits as possible; Take Jesus
            > Christ out, if possible; Loose "I fart in your general direction"; Lose
            > "the oral sex"; Lose "oh, fuck off"; Lose "We make castanets out of your
            > testicles"
            > "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
            >
            > /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
            > /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
            > \\\ an exciting new programming language -- http://www.Zimbu.org ///
            > \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

            This would be one great addition to vim if the patch gets accepted.

            --
            --
            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

            ---
            You received this message because you are subscribed to the Google Groups "vim_dev" group.
            To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
            For more options, visit https://groups.google.com/d/optout.
          Your message has been successfully submitted and would be delivered to recipients shortly.