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

Expand Messages
  • Benjamin Fritz
    I use the delimitMate plugin by Israel Chauca Fuentes: http://www.vim.org/scripts/script.php?script_id=2754 https://github.com/Raimondi/delimitMate I found
    Message 1 of 18 , Jul 3, 2013
      I use the delimitMate plugin by Israel Chauca Fuentes:

      http://www.vim.org/scripts/script.php?script_id=2754
      https://github.com/Raimondi/delimitMate

      I found this plugin to be "the best" at automatically inserting the
      closing character for "paired" characters like (..), [..], etc. It is
      customizeable, and until recently, did not affect undo/redo/repeat.

      But, this plugin uses setline() internally, taking advantage of the
      "bug" fixed recently, that calling setline() in insert mode does not
      break the undo sequence. So, in Vim 7.3.1169, I can type the following:

      aone two three<Esc>

      Pressing 'u' would undo the entire insertion. With 7.3.1298, pressing
      'u' removes each word individually, because <Space> triggers some logic
      in delimitMate.

      It is even more annoying when delimitMate actually inserts anything.
      Typing the following with delimitMate installed:

      aone two(three<Esc>

      Will actually insert the text:

      one two(three)

      So far, so good. Pressing '.' to repeat likewise still works. But when
      pressing 'u', in 1169 the entire insert is undone. In 1298, the first
      press gets rid of three) and the second press gets rid of the rest.

      Similar problems also occur when using the mapping to skip past an
      existing ) instead of inserting a new one when pressing ) in insert
      mode.

      I think, what is needed, is a method in insert mode, to insert text
      after the cursor and/or move the cursor, without breaking the undo
      sequence. The setline() thing was always a hack, I admit.

      Oddly it looks like Israel's name is on the 7.3.1200 issue description,
      so presumably he's aware of this. But the latest version of his plugin
      from GitHub breaks as described. And honestly I think it somewhat
      strange that I need a complicated plugin using setline(), etc. to avoid
      breaking undo/redo for something as simple as inserting an extra ) while
      typing in insert mode, or moving the cursor beyond the ) when typing a
      new one.

      --
      --
      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/groups/opt_out.
    • Ben Fritz
      Responding mainly to set a topic. Sorry about that. Normally gmail warns me about not having a subject. Not today apparently. I have seen this hack in other
      Message 2 of 18 , Jul 3, 2013
        Responding mainly to set a topic. Sorry about that. Normally gmail warns me about not having a subject. Not today apparently.

        I have seen this hack in other plugins as well, mostly related to automatically adding text or moving the cursor in insert mode.

        On Wednesday, July 3, 2013 3:45:32 PM UTC-5, Ben Fritz wrote:
        > I use the delimitMate plugin by Israel Chauca Fuentes:
        >
        >
        >
        > http://www.vim.org/scripts/script.php?script_id=2754
        >
        > https://github.com/Raimondi/delimitMate
        >
        >
        >
        > I found this plugin to be "the best" at automatically inserting the
        >
        > closing character for "paired" characters like (..), [..], etc. It is
        >
        > customizeable, and until recently, did not affect undo/redo/repeat.
        >
        >
        >
        > But, this plugin uses setline() internally, taking advantage of the
        >
        > "bug" fixed recently, that calling setline() in insert mode does not
        >
        > break the undo sequence. So, in Vim 7.3.1169, I can type the following:
        >
        >
        >
        > aone two three<Esc>
        >
        >
        >
        > Pressing 'u' would undo the entire insertion. With 7.3.1298, pressing
        >
        > 'u' removes each word individually, because <Space> triggers some logic
        >
        > in delimitMate.
        >
        >
        >
        > It is even more annoying when delimitMate actually inserts anything.
        >
        > Typing the following with delimitMate installed:
        >
        >
        >
        > aone two(three<Esc>
        >
        >
        >
        > Will actually insert the text:
        >
        >
        >
        > one two(three)
        >
        >
        >
        > So far, so good. Pressing '.' to repeat likewise still works. But when
        >
        > pressing 'u', in 1169 the entire insert is undone. In 1298, the first
        >
        > press gets rid of three) and the second press gets rid of the rest.
        >
        >
        >
        > Similar problems also occur when using the mapping to skip past an
        >
        > existing ) instead of inserting a new one when pressing ) in insert
        >
        > mode.
        >
        >
        >
        > I think, what is needed, is a method in insert mode, to insert text
        >
        > after the cursor and/or move the cursor, without breaking the undo
        >
        > sequence. The setline() thing was always a hack, I admit.
        >
        >
        >
        > Oddly it looks like Israel's name is on the 7.3.1200 issue description,
        >
        > so presumably he's aware of this. But the latest version of his plugin
        >
        > from GitHub breaks as described. And honestly I think it somewhat
        >
        > strange that I need a complicated plugin using setline(), etc. to avoid
        >
        > breaking undo/redo for something as simple as inserting an extra ) while
        >
        > typing in insert mode, or moving the cursor beyond the ) when typing a
        >
        > new one.

        --
        --
        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/groups/opt_out.
      • Bram Moolenaar
        ... Perhaps we can somehow detect that CTRL-R = had the side effect of changing the text and then split undo. When it only returns the text to be inserted,
        Message 3 of 18 , Jul 4, 2013
          Ben Fritz write:

          > I use the delimitMate plugin by Israel Chauca Fuentes:
          >
          > http://www.vim.org/scripts/script.php?script_id=2754
          > https://github.com/Raimondi/delimitMate
          >
          > I found this plugin to be "the best" at automatically inserting the
          > closing character for "paired" characters like (..), [..], etc. It is
          > customizeable, and until recently, did not affect undo/redo/repeat.
          >
          > But, this plugin uses setline() internally, taking advantage of the
          > "bug" fixed recently, that calling setline() in insert mode does not
          > break the undo sequence. So, in Vim 7.3.1169, I can type the following:
          >
          > aone two three<Esc>
          >
          > Pressing 'u' would undo the entire insertion. With 7.3.1298, pressing
          > 'u' removes each word individually, because <Space> triggers some logic
          > in delimitMate.
          >
          > It is even more annoying when delimitMate actually inserts anything.
          > Typing the following with delimitMate installed:
          >
          > aone two(three<Esc>
          >
          > Will actually insert the text:
          >
          > one two(three)
          >
          > So far, so good. Pressing '.' to repeat likewise still works. But when
          > pressing 'u', in 1169 the entire insert is undone. In 1298, the first
          > press gets rid of three) and the second press gets rid of the rest.
          >
          > Similar problems also occur when using the mapping to skip past an
          > existing ) instead of inserting a new one when pressing ) in insert
          > mode.
          >
          > I think, what is needed, is a method in insert mode, to insert text
          > after the cursor and/or move the cursor, without breaking the undo
          > sequence. The setline() thing was always a hack, I admit.
          >
          > Oddly it looks like Israel's name is on the 7.3.1200 issue description,
          > so presumably he's aware of this. But the latest version of his plugin
          > from GitHub breaks as described. And honestly I think it somewhat
          > strange that I need a complicated plugin using setline(), etc. to avoid
          > breaking undo/redo for something as simple as inserting an extra ) while
          > typing in insert mode, or moving the cursor beyond the ) when typing a
          > new one.

          Perhaps we can somehow detect that CTRL-R = had the side effect of
          changing the text and then split undo. When it only returns the text to
          be inserted, there is no need to split undo.

          Does the delimitMate return the text to be inserted or does it use
          setline()? In the last case it can't be fixed really.

          --
          My girlfriend told me I should be more affectionate.
          So I got TWO girlfriends.

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

          ---
          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/groups/opt_out.
        • Benjamin Fritz
          ... It actually uses setline(). I think we might need a new (intentional) feature that allows moving the cursor in insert mode without breaking undo, or,
          Message 4 of 18 , Jul 8, 2013
            On Thu, Jul 4, 2013 at 4:44 AM, Bram Moolenaar <Bram@...> wrote:
            > Does the delimitMate return the text to be inserted or does it use
            > setline()? In the last case it can't be fixed really.


            It actually uses setline().

            I think we might need a new (intentional) feature that allows moving
            the cursor in insert mode without breaking undo, or, something like
            undojoin that allows chaining the next insert with this one.

            Basically I want something that allows mappings like here:

            http://vim.wikia.com/wiki/Automatically_append_closing_characters

            to not break the undo sequence.

            At least, delimitMate still doesn't break repeating with '.'; only undo/redo.

            --
            --
            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/groups/opt_out.
          • Bram Moolenaar
            ... Why? What does it do that can t be done by returning a string? ... -- Yesterday, all my deadlines seemed so far away now it looks as though it s freeze in
            Message 5 of 18 , Jul 8, 2013
              Benjamin Fritz wrote:

              > On Thu, Jul 4, 2013 at 4:44 AM, Bram Moolenaar <Bram@...> wrote:
              > > Does the delimitMate return the text to be inserted or does it use
              > > setline()? In the last case it can't be fixed really.
              >
              > It actually uses setline().

              Why? What does it do that can't be done by returning a string?

              > I think we might need a new (intentional) feature that allows moving
              > the cursor in insert mode without breaking undo, or, something like
              > undojoin that allows chaining the next insert with this one.
              >
              > Basically I want something that allows mappings like here:
              >
              > http://vim.wikia.com/wiki/Automatically_append_closing_characters
              >
              > to not break the undo sequence.
              >
              > At least, delimitMate still doesn't break repeating with '.'; only undo/redo.

              --
              Yesterday, all my deadlines seemed so far away
              now it looks as though it's freeze in four days
              oh I believe in cvs..
              [ CVS log "Beatles style" for FreeBSD ports/INDEX, Satoshi Asami ]

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

              ---
              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/groups/opt_out.
            • Benjamin Fritz
              ... Type: iabc( get (where | is the cursor): abc(|) now continue typing 123) + 456; get: abc(123) + 456;| Note how the parenthesis got inserted automatically,
              Message 6 of 18 , Jul 8, 2013
                On Mon, Jul 8, 2013 at 1:59 PM, Bram Moolenaar <Bram@...> wrote:
                >
                > Benjamin Fritz wrote:
                >
                >> On Thu, Jul 4, 2013 at 4:44 AM, Bram Moolenaar <Bram@...> wrote:
                >> > Does the delimitMate return the text to be inserted or does it use
                >> > setline()? In the last case it can't be fixed really.
                >>
                >> It actually uses setline().
                >
                > Why? What does it do that can't be done by returning a string?
                >

                Type:

                iabc(

                get (where | is the cursor):

                abc(|)

                now continue typing 123) + 456;

                get:

                abc(123) + 456;|

                Note how the parenthesis got inserted automatically, but manually
                entering ) did not insert a second ) but rather moved the cursor over
                the existing one.

                --
                --
                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/groups/opt_out.
              • Bram Moolenaar
                ... That can be done by returning cursor key sequences. No need for setline(): imap ( =LeftParen() fun! LeftParen() return () endfun imap )
                Message 7 of 18 , Jul 9, 2013
                  Ben Fritz wrote:

                  > On Mon, Jul 8, 2013 at 1:59 PM, Bram Moolenaar <Bram@...> wrote:
                  > >
                  > > Benjamin Fritz wrote:
                  > >
                  > >> On Thu, Jul 4, 2013 at 4:44 AM, Bram Moolenaar <Bram@...> wrote:
                  > >> > Does the delimitMate return the text to be inserted or does it use
                  > >> > setline()? In the last case it can't be fixed really.
                  > >>
                  > >> It actually uses setline().
                  > >
                  > > Why? What does it do that can't be done by returning a string?
                  > >
                  >
                  > Type:
                  >
                  > iabc(
                  >
                  > get (where | is the cursor):
                  >
                  > abc(|)
                  >
                  > now continue typing 123) + 456;
                  >
                  > get:
                  >
                  > abc(123) + 456;|
                  >
                  > Note how the parenthesis got inserted automatically, but manually
                  > entering ) did not insert a second ) but rather moved the cursor over
                  > the existing one.

                  That can be done by returning cursor key sequences. No need for
                  setline():

                  imap ( <C-R>=LeftParen()<CR>
                  fun! LeftParen()
                  return "()\<Left>"
                  endfun
                  imap ) <C-R>=RightParen()<CR>
                  fun! RightParen()
                  return "\<Right>"
                  endfun

                  --
                  Violators can be fined, arrested or jailed for making ugly faces at a dog.
                  [real standing law in Oklahoma, United States of America]

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

                  ---
                  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/groups/opt_out.
                • Benjamin Fritz
                  ... I don t remember how setline() solves the problem, but just returning cursor sequences doesn t work, because it breaks undo/redo/repeat. If I insert
                  Message 8 of 18 , Jul 9, 2013
                    On Tue, Jul 9, 2013 at 5:54 AM, Bram Moolenaar <Bram@...> wrote:
                    >
                    > That can be done by returning cursor key sequences. No need for
                    > setline():
                    >
                    > imap ( <C-R>=LeftParen()<CR>
                    > fun! LeftParen()
                    > return "()\<Left>"
                    > endfun
                    > imap ) <C-R>=RightParen()<CR>
                    > fun! RightParen()
                    > return "\<Right>"
                    > endfun
                    >

                    I don't remember how setline() solves the problem, but just returning
                    cursor sequences doesn't work, because it breaks undo/redo/repeat.

                    If I insert abc(123) with mappings like, then press '.' somewhere
                    else, I will only get the 123 inserted. Pressing 'u' after inserting
                    "abc(123) + 456" will only undo the " + 456".

                    The mappings that used to work to get around this are complicated;
                    hence the reason I'm using a plugin instead of simple mappings; but
                    previously somehow using setline() allowed all of undo, redo, and
                    repeat to work as if there were not any mappings. Now only repeat
                    works.

                    --
                    --
                    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/groups/opt_out.
                  • Bram Moolenaar
                    ... Yeah, that s true. I suppose we could avoid saving for undo under certain conditions, but it s quite hard to decide what those conditions are. Perhaps
                    Message 9 of 18 , Jul 9, 2013
                      Ben Fritz wrote:

                      > On Tue, Jul 9, 2013 at 5:54 AM, Bram Moolenaar <Bram@...> wrote:
                      > >
                      > > That can be done by returning cursor key sequences. No need for
                      > > setline():
                      > >
                      > > imap ( <C-R>=LeftParen()<CR>
                      > > fun! LeftParen()
                      > > return "()\<Left>"
                      > > endfun
                      > > imap ) <C-R>=RightParen()<CR>
                      > > fun! RightParen()
                      > > return "\<Right>"
                      > > endfun
                      > >
                      >
                      > I don't remember how setline() solves the problem, but just returning
                      > cursor sequences doesn't work, because it breaks undo/redo/repeat.

                      Yeah, that's true. I suppose we could avoid saving for undo under
                      certain conditions, but it's quite hard to decide what those conditions
                      are. Perhaps "when inserting a register and the cursor remains within
                      the inserted text"?

                      > If I insert abc(123) with mappings like, then press '.' somewhere
                      > else, I will only get the 123 inserted. Pressing 'u' after inserting
                      > "abc(123) + 456" will only undo the " + 456".
                      >
                      > The mappings that used to work to get around this are complicated;
                      > hence the reason I'm using a plugin instead of simple mappings; but
                      > previously somehow using setline() allowed all of undo, redo, and
                      > repeat to work as if there were not any mappings. Now only repeat
                      > works.

                      --
                      "I love deadlines. I especially like the whooshing sound they
                      make as they go flying by."
                      -- Douglas Adams

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

                      ---
                      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/groups/opt_out.
                    • Ben Fritz
                      ... Is that easier than an explicit normally the next movement would break the undo sequence but I don t want it to keystroke or command? Something like the
                      Message 10 of 18 , Jul 9, 2013
                        On Tuesday, July 9, 2013 10:13:22 AM UTC-5, Bram Moolenaar wrote:
                        > Ben Fritz wrote:
                        >
                        > > I don't remember how setline() solves the problem, but just returning
                        >
                        > > cursor sequences doesn't work, because it breaks undo/redo/repeat.
                        >
                        >
                        >
                        > Yeah, that's true. I suppose we could avoid saving for undo under
                        >
                        > certain conditions, but it's quite hard to decide what those conditions
                        >
                        > are. Perhaps "when inserting a register and the cursor remains within
                        >
                        > the inserted text"?
                        >

                        Is that easier than an explicit "normally the next movement would break the undo sequence but I don't want it to" keystroke or command? Something like the inverse of i_CTRL-G_u. Then you could simply do something like:

                        inoremap ( ()<C-G>U<Left>
                        inoremap <expr> ) (NextChar()==')' ? "\<C-G>U\<Right>" : ")")

                        Really I don't care HOW it's accomplished as long as it is possible to move the cursor in insert mode one or two characters without breaking undo. If allowing limited cursor movement when inserting a register is easy enough, I can probably work with that.

                        --
                        --
                        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/groups/opt_out.
                      • Ben Fritz
                        ... Even though it won t fix it all the way, I think this is a good idea. It will make things a lot better at least. Then we can do this obviously simplified
                        Message 11 of 18 , Jul 11, 2013
                          On Thursday, July 4, 2013 4:44:26 AM UTC-5, Bram Moolenaar wrote:
                          >
                          > Perhaps we can somehow detect that CTRL-R = had the side effect of
                          >
                          > changing the text and then split undo. When it only returns the text to
                          >
                          > be inserted, there is no need to split undo.
                          >

                          Even though it won't fix it all the way, I think this is a good idea. It will make things a lot better at least.

                          Then we can do this obviously simplified example without breaking undo:

                          inoremap <Space> <C-R>="\<LT>Space>"<CR>

                          --
                          --
                          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/groups/opt_out.
                        • Benjamin Fritz
                          ... Wasn t this supposedly fixed? 7.3.1290 (after 7.3.1253) CTRL-R = in Insert mode starts new insert -- -- You received this message from the vim_dev
                          Message 12 of 18 , Jul 11, 2013
                            On Thu, Jul 11, 2013 at 10:36 AM, Ben Fritz <fritzophrenic@...> wrote:
                            > On Thursday, July 4, 2013 4:44:26 AM UTC-5, Bram Moolenaar wrote:
                            >>
                            >> Perhaps we can somehow detect that CTRL-R = had the side effect of
                            >>
                            >> changing the text and then split undo. When it only returns the text to
                            >>
                            >> be inserted, there is no need to split undo.
                            >>
                            >
                            > Even though it won't fix it all the way, I think this is a good idea. It will make things a lot better at least.
                            >
                            > Then we can do this obviously simplified example without breaking undo:
                            >
                            > inoremap <Space> <C-R>="\<LT>Space>"<CR>

                            Wasn't this supposedly fixed?

                            7.3.1290 (after 7.3.1253) CTRL-R = in Insert mode starts new insert

                            --
                            --
                            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/groups/opt_out.
                          • Christian Brabandt
                            ... Wouldn t in this example CTRL-R= also change the text and therefore break undo here as well? regards, Christian -- -- You received this message from the
                            Message 13 of 18 , Jul 11, 2013
                              On Thu, July 11, 2013 17:36, Ben Fritz wrote:
                              > On Thursday, July 4, 2013 4:44:26 AM UTC-5, Bram Moolenaar wrote:
                              >>
                              >> Perhaps we can somehow detect that CTRL-R = had the side effect of
                              >>
                              >> changing the text and then split undo. When it only returns the text to
                              >>
                              >> be inserted, there is no need to split undo.
                              >>
                              >
                              > Even though it won't fix it all the way, I think this is a good idea. It
                              > will make things a lot better at least.
                              >
                              > Then we can do this obviously simplified example without breaking undo:
                              >
                              > inoremap <Space> <C-R>="\<LT>Space>"<CR>

                              Wouldn't in this example CTRL-R= also change the text and therefore break
                              undo here as well?

                              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

                              ---
                              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/groups/opt_out.
                            • Christian Brabandt
                              ... No, that fixes the problem that ctrl-r = in insert mode changes the position of the [ mark. regards, Christian -- -- You received this message from the
                              Message 14 of 18 , Jul 11, 2013
                                On Thu, July 11, 2013 17:41, Benjamin Fritz wrote:
                                > On Thu, Jul 11, 2013 at 10:36 AM, Ben Fritz <fritzophrenic@...>
                                > wrote:
                                >> On Thursday, July 4, 2013 4:44:26 AM UTC-5, Bram Moolenaar wrote:
                                >>>
                                >>> Perhaps we can somehow detect that CTRL-R = had the side effect of
                                >>>
                                >>> changing the text and then split undo. When it only returns the text
                                >>> to
                                >>>
                                >>> be inserted, there is no need to split undo.
                                >>>
                                >>
                                >> Even though it won't fix it all the way, I think this is a good idea. It
                                >> will make things a lot better at least.
                                >>
                                >> Then we can do this obviously simplified example without breaking undo:
                                >>
                                >> inoremap <Space> <C-R>="\<LT>Space>"<CR>
                                >
                                > Wasn't this supposedly fixed?
                                >
                                > 7.3.1290 (after 7.3.1253) CTRL-R = in Insert mode starts new insert
                                >

                                No, that fixes the problem that ctrl-r = in insert mode changes the
                                position of the '[ mark.

                                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

                                ---
                                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/groups/opt_out.
                              • Ben Fritz
                                ... It doesn t change the text directly, it only returns a value. Actually this mapping seems to work now that I try it again. I m not sure what I did
                                Message 15 of 18 , Jul 11, 2013
                                  On Thursday, July 11, 2013 10:45:16 AM UTC-5, Christian Brabandt wrote:
                                  > On Thu, July 11, 2013 17:36, Ben Fritz wrote:
                                  >
                                  > > On Thursday, July 4, 2013 4:44:26 AM UTC-5, Bram Moolenaar wrote:
                                  >
                                  > >>
                                  >
                                  > >> Perhaps we can somehow detect that CTRL-R = had the side effect of
                                  >
                                  > >>
                                  >
                                  > >> changing the text and then split undo. When it only returns the text to
                                  >
                                  > >>
                                  >
                                  > >> be inserted, there is no need to split undo.
                                  >
                                  > >>
                                  >
                                  > >
                                  >
                                  > > Even though it won't fix it all the way, I think this is a good idea. It
                                  >
                                  > > will make things a lot better at least.
                                  >
                                  > >
                                  >
                                  > > Then we can do this obviously simplified example without breaking undo:
                                  >
                                  > >
                                  >
                                  > > inoremap <Space> <C-R>="\<LT>Space>"<CR>
                                  >
                                  >
                                  >
                                  > Wouldn't in this example CTRL-R= also change the text and therefore break
                                  >
                                  > undo here as well?
                                  >

                                  It doesn't change the text directly, it only returns a value.

                                  Actually this mapping seems to work now that I try it again. I'm not sure what I did differently when it didn't work the first time I tried. Something is making me unable to use delimitMate, because even if set the option that makes the <Space> mapping simply return a space, the undo sequence breaks on every space insertion.

                                  This is closer to what is actually going on in delimitMate, but I still can't reproduce the issue. I will try again later to get a smaller example:

                                  function! Space()
                                  return "\<Space>"
                                  endfun

                                  inoremap flarbityflarb <C-]><C-R>=Space()<CR>

                                  imap <Space> <C-]>flarbityflarb

                                  --
                                  --
                                  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/groups/opt_out.
                                • dag.odenhall@gmail.com
                                  I d like to note that this trick never quite worked anyway. For example if you do i test .uu in a new buffer you end up with two empty lines even
                                  Message 16 of 18 , Jul 12, 2013

                                    I'd like to note that this trick never quite worked anyway. For example if you do i"test"<CR><Esc>.uu in a new buffer you end up with two empty lines even though you're at the “oldest” change. This could be another bug with setline(), I suppose.



                                    On Thu, Jul 11, 2013 at 6:57 PM, Ben Fritz <fritzophrenic@...> wrote:
                                    On Thursday, July 11, 2013 10:45:16 AM UTC-5, Christian Brabandt wrote:
                                    > On Thu, July 11, 2013 17:36, Ben Fritz wrote:
                                    >
                                    > > On Thursday, July 4, 2013 4:44:26 AM UTC-5, Bram Moolenaar wrote:
                                    >
                                    > >>
                                    >
                                    > >> Perhaps we can somehow detect that CTRL-R = had the side effect of
                                    >
                                    > >>
                                    >
                                    > >> changing the text and then split undo.  When it only returns the text to
                                    >
                                    > >>
                                    >
                                    > >> be inserted, there is no need to split undo.
                                    >
                                    > >>
                                    >
                                    > >
                                    >
                                    > > Even though it won't fix it all the way, I think this is a good idea. It
                                    >
                                    > > will make things a lot better at least.
                                    >
                                    > >
                                    >
                                    > > Then we can do this obviously simplified example without breaking undo:
                                    >
                                    > >
                                    >
                                    > > inoremap <Space> <C-R>="\<LT>Space>"<CR>
                                    >
                                    >
                                    >
                                    > Wouldn't in this example CTRL-R= also change the text and therefore break
                                    >
                                    > undo here as well?
                                    >

                                    It doesn't change the text directly, it only returns a value.

                                    Actually this mapping seems to work now that I try it again. I'm not sure what I did differently when it didn't work the first time I tried. Something is making me unable to use delimitMate, because even if set the option that makes the <Space> mapping simply return a space, the undo sequence breaks on every space insertion.

                                    This is closer to what is actually going on in delimitMate, but I still can't reproduce the issue. I will try again later to get a smaller example:

                                    function! Space()
                                      return "\<Space>"
                                    endfun

                                    inoremap flarbityflarb  <C-]><C-R>=Space()<CR>

                                    imap <Space> <C-]>flarbityflarb

                                    --
                                    --
                                    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/groups/opt_out.



                                    --
                                    --
                                    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/groups/opt_out.
                                     
                                     
                                  • Thiago Alves
                                    Hi guys, I m the author of AutoClose and since almost a year ago I gave up trying to fix all sort of problems caused by inventive solutions to workaround the
                                    Message 17 of 18 , Jul 12, 2013
                                      Hi guys, I'm the author of AutoClose and since almost a year ago I gave up trying to fix all sort of problems caused by inventive solutions to "workaround" the undo break.

                                      I really like Bram's idea where <C-R>= would break the undo. If we have that auto complete plugins would be way more simple to implement.

                                      Is anyone working on this patch at this point?

                                      On Wednesday, July 3, 2013 1:45:32 PM UTC-7, Ben Fritz wrote:
                                      > I use the delimitMate plugin by Israel Chauca Fuentes:
                                      >
                                      >
                                      >
                                      > http://www.vim.org/scripts/script.php?script_id=2754
                                      >
                                      > https://github.com/Raimondi/delimitMate
                                      >
                                      >
                                      >
                                      > I found this plugin to be "the best" at automatically inserting the
                                      >
                                      > closing character for "paired" characters like (..), [..], etc. It is
                                      >
                                      > customizeable, and until recently, did not affect undo/redo/repeat.
                                      >
                                      >
                                      >
                                      > But, this plugin uses setline() internally, taking advantage of the
                                      >
                                      > "bug" fixed recently, that calling setline() in insert mode does not
                                      >
                                      > break the undo sequence. So, in Vim 7.3.1169, I can type the following:
                                      >
                                      >
                                      >
                                      > aone two three<Esc>
                                      >
                                      >
                                      >
                                      > Pressing 'u' would undo the entire insertion. With 7.3.1298, pressing
                                      >
                                      > 'u' removes each word individually, because <Space> triggers some logic
                                      >
                                      > in delimitMate.
                                      >
                                      >
                                      >
                                      > It is even more annoying when delimitMate actually inserts anything.
                                      >
                                      > Typing the following with delimitMate installed:
                                      >
                                      >
                                      >
                                      > aone two(three<Esc>
                                      >
                                      >
                                      >
                                      > Will actually insert the text:
                                      >
                                      >
                                      >
                                      > one two(three)
                                      >
                                      >
                                      >
                                      > So far, so good. Pressing '.' to repeat likewise still works. But when
                                      >
                                      > pressing 'u', in 1169 the entire insert is undone. In 1298, the first
                                      >
                                      > press gets rid of three) and the second press gets rid of the rest.
                                      >
                                      >
                                      >
                                      > Similar problems also occur when using the mapping to skip past an
                                      >
                                      > existing ) instead of inserting a new one when pressing ) in insert
                                      >
                                      > mode.
                                      >
                                      >
                                      >
                                      > I think, what is needed, is a method in insert mode, to insert text
                                      >
                                      > after the cursor and/or move the cursor, without breaking the undo
                                      >
                                      > sequence. The setline() thing was always a hack, I admit.
                                      >
                                      >
                                      >
                                      > Oddly it looks like Israel's name is on the 7.3.1200 issue description,
                                      >
                                      > so presumably he's aware of this. But the latest version of his plugin
                                      >
                                      > from GitHub breaks as described. And honestly I think it somewhat
                                      >
                                      > strange that I need a complicated plugin using setline(), etc. to avoid
                                      >
                                      > breaking undo/redo for something as simple as inserting an extra ) while
                                      >
                                      > typing in insert mode, or moving the cursor beyond the ) when typing a
                                      >
                                      > new one.

                                      --
                                      --
                                      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/groups/opt_out.
                                    • Thiago Alves
                                      Hi guys, I m the author of AutoClose and since almost a year ago I gave up trying to fix all sort of problems caused by inventive solutions to workaround the
                                      Message 18 of 18 , Jul 12, 2013
                                        Hi guys, I'm the author of AutoClose and since almost a year ago I gave up trying to fix all sort of problems caused by inventive solutions to "workaround" the undo break.
                                        I really like Bram's idea where <C-R>= would not break the undo. If we have that auto complete plugins would be way more simple to implement.

                                        Is anyone working on this patch at this point?

                                        On Tuesday, July 9, 2013 8:13:22 AM UTC-7, Bram Moolenaar wrote:
                                        > Ben Fritz wrote:
                                        >
                                        >
                                        >
                                        > > On Tue, Jul 9, 2013 at 5:54 AM, Bram Moolenaar <Bram@...> wrote:
                                        >
                                        > > >
                                        >
                                        > > > That can be done by returning cursor key sequences. No need for
                                        >
                                        > > > setline():
                                        >
                                        > > >
                                        >
                                        > > > imap ( <C-R>=LeftParen()<CR>
                                        >
                                        > > > fun! LeftParen()
                                        >
                                        > > > return "()\<Left>"
                                        >
                                        > > > endfun
                                        >
                                        > > > imap ) <C-R>=RightParen()<CR>
                                        >
                                        > > > fun! RightParen()
                                        >
                                        > > > return "\<Right>"
                                        >
                                        > > > endfun
                                        >
                                        > > >
                                        >
                                        > >
                                        >
                                        > > I don't remember how setline() solves the problem, but just returning
                                        >
                                        > > cursor sequences doesn't work, because it breaks undo/redo/repeat.
                                        >
                                        >
                                        >
                                        > Yeah, that's true. I suppose we could avoid saving for undo under
                                        >
                                        > certain conditions, but it's quite hard to decide what those conditions
                                        >
                                        > are. Perhaps "when inserting a register and the cursor remains within
                                        >
                                        > the inserted text"?
                                        >
                                        >
                                        >
                                        > > If I insert abc(123) with mappings like, then press '.' somewhere
                                        >
                                        > > else, I will only get the 123 inserted. Pressing 'u' after inserting
                                        >
                                        > > "abc(123) + 456" will only undo the " + 456".
                                        >
                                        > >
                                        >
                                        > > The mappings that used to work to get around this are complicated;
                                        >
                                        > > hence the reason I'm using a plugin instead of simple mappings; but
                                        >
                                        > > previously somehow using setline() allowed all of undo, redo, and
                                        >
                                        > > repeat to work as if there were not any mappings. Now only repeat
                                        >
                                        > > works.
                                        >
                                        >
                                        >
                                        > --
                                        >
                                        > "I love deadlines. I especially like the whooshing sound they
                                        >
                                        > make as they go flying by."
                                        >
                                        > -- Douglas Adams
                                        >
                                        >
                                        >
                                        > /// 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

                                        ---
                                        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/groups/opt_out.
                                      Your message has been successfully submitted and would be delivered to recipients shortly.