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

Re: "." fails to repeat the last executed operator with ":normal v"

Expand Messages
  • glts
    Sung Pae, thank you for your feedback. ... Yes, but this is due to another bug. My patch does not affect this. ... If you try the normal mode mapping, e.g.
    Message 1 of 19 , Mar 24, 2013
    • 0 Attachment
      Sung Pae, thank you for your feedback.

      On Sun, Mar 24, 2013 at 12:40 AM, Sung Pae <self@...> wrote:
      > I see two issues on first glance:
      >
      > * Counts are not repeated; d2x (x being a custom motion) repeats as
      > dx only

      Yes, but this is due to another bug. My patch does not affect this.

      The v:count variables are treated differently in omaps. Compare:

      :nnoremap <silent> x :<C-U>exe "norm! d".v:count1."e"<CR>
      :onoremap <silent> x :<C-U>exe "norm! ".v:count1."e"<CR>

      If you try the normal mode mapping, e.g. "2x", then the dot command will
      have the same effect as "2x". You can also override the count by giving
      a count to the dot command, e.g. "3.". This is the expected behaviour.

      The omap on the other hand doesn't work like that. Try "d2x" and then
      repeat with the dot command: The original count is not used. You have to
      use "2." to get the same as with "d2x".

      This is a different issue, and I'd rather put it off for the moment.

      > * Making a visual selection with a custom operator clobbers the redo

      Can you give an example? I don't see the problem.

      --
      --
      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.
    • Sung Pae
      ... Ah yes, you re totally correct. I remember now that I had to work around that myself by saving v:count to a buffer-local variable on omap invocation, then
      Message 2 of 19 , Mar 24, 2013
      • 0 Attachment
        On Sun, Mar 24, 2013 at 06:43:47PM +0100, glts wrote:

        > On Sun, Mar 24, 2013 at 12:40 AM, Sung Pae <self@...> wrote:
        > > I see two issues on first glance:
        > >
        > > * Counts are not repeated; d2x (x being a custom motion) repeats as
        > > dx only
        >
        > Yes, but this is due to another bug. My patch does not affect this.
        >
        > The v:count variables are treated differently in omaps. Compare:

        Ah yes, you're totally correct. I remember now that I had to work
        around that myself by saving v:count to a buffer-local variable on omap
        invocation, then string-replace the v:count variable in the omap rhs
        with the buffer-local "b:_count", so that the cached value would be used
        on repeat. It was very nasty, but it worked.

        > This is a different issue, and I'd rather put it off for the moment.

        Yes, I imagine a new count variable needs to be created to handle omaps.

        > > * Making a visual selection with a custom operator clobbers the redo
        >
        > Can you give an example? I don't see the problem.

        I apologize, that was a bit vague.

        Let's create a simple (and incomplete) custom motion:

        function! SelectInCaps()
        let [bl, bc] = searchpos('\u', 'cbW')
        let [el, ec] = searchpos('.\u\ze', 'W')
        call setpos("'<", [0, bl, bc, 0])
        call setpos("'>", [0, el, ec, 0])
        normal! gv
        endfunction

        Then map it to both visual and operator-pending modes:

        vmap ic :<C-U>call SelectInCaps()<CR>
        omap ic :<C-U>call SelectInCaps()<CR>

        Repeating the command dic with the . command works now with your patch:

        Foo|BarBazQuux
        Foo|BazQuux " dic
        Foo|Quuz " .

        However, if we invoke vic after running dic, the . command no longer has
        any affect:

        Foo|BarBazQuux
        Foo|BazQuux " dic
        Foo|BazQuux " vic<Esc>
        Foo|BazQuux " .

        This is not true of the builtin motions like `aw`; visual commands do
        not clobber the repeat buffer (or however it may work).

        Thank you for your work on this!

        Sung Pae

        --
        --
        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.
      • glts
        ... Yes, sorry, and thanks for reporting. Operator and Visual mode handling isn t easy and I m learning it the hard way ... Anyway, after another session in
        Message 3 of 19 , Mar 25, 2013
        • 0 Attachment
          On Mon, Mar 25, 2013 at 2:08 AM, Sung Pae <self@...> wrote:
          > Let's create a simple (and incomplete) custom motion:
          >
          > function! SelectInCaps()
          > let [bl, bc] = searchpos('\u', 'cbW')
          > let [el, ec] = searchpos('.\u\ze', 'W')
          > call setpos("'<", [0, bl, bc, 0])
          > call setpos("'>", [0, el, ec, 0])
          > normal! gv
          > endfunction
          >
          > Then map it to both visual and operator-pending modes:
          >
          > vmap ic :<C-U>call SelectInCaps()<CR>
          > omap ic :<C-U>call SelectInCaps()<CR>
          >
          > Repeating the command dic with the . command works now with your patch:
          >
          > Foo|BarBazQuux
          > Foo|BazQuux " dic
          > Foo|Quuz " .
          >
          > However, if we invoke vic after running dic, the . command no longer has
          > any affect:
          >
          > Foo|BarBazQuux
          > Foo|BazQuux " dic
          > Foo|BazQuux " vic<Esc>
          > Foo|BazQuux " .

          Yes, sorry, and thanks for reporting. Operator and Visual mode handling
          isn't easy and I'm learning it the hard way ...

          Anyway, after another session in the debugger I came up with the slight
          amendment in the attachment. If you would like to try it, be my guest. I
          hope I can find the time to write a few tests.

          David

          --
          --
          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.
        • Sung Pae
          ... Yes, this definitely solves the problem with visual selections clearing the repeat. I tried poking around a bit more, and I couldn t find any obvious
          Message 4 of 19 , Mar 25, 2013
          • 0 Attachment
            On Mon, Mar 25, 2013 at 10:14:48PM +0100, glts wrote:

            > On Mon, Mar 25, 2013 at 2:08 AM, Sung Pae <self@...> wrote:
            >
            > > Let's create a simple (and incomplete) custom motion: …
            >
            > Anyway, after another session in the debugger I came up with the
            > slight amendment in the attachment. If you would like to try it, be my
            > guest. I hope I can find the time to write a few tests.

            Yes, this definitely solves the problem with visual selections clearing
            the repeat. I tried poking around a bit more, and I couldn't find any
            obvious problems, which is exciting.

            All that appears to be left to achieve parity with builtin cursor
            motions is the issue with v:count. I will report any problems should I
            find them.

            Thank you for looking into this.

            Sung Pae

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