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

[PATCH] Allow setpos() to push jump list

Expand Messages
  • guns
    Hello, In the documentation for :jumplist, it is mentioned that You can explicitly add a jump by setting the mark. This is true by pressing m and m` in
    Message 1 of 6 , Jul 12, 2013
    • 0 Attachment
      Hello,

      In the documentation for :jumplist, it is mentioned that

      You can explicitly add a jump by setting the ' mark.

      This is true by pressing m' and m` in normal mode, but it does not work
      by calling the equivalent :call setpos("''", getpos('.')).

      I am unsure if this is intentional, but if not, this patch addresses
      this issue (*pos and curwin->w_cursor were compared by identity, not
      value).

      I could not find an appropriate test script to append, so I took the
      liberty of adding test99.in and test99.ok.

      Thank you,
      Sung Pae
    • Ingo Karkat
      ... I had noticed that, too, so changing this might break existing plugins / macros. On the other hand (providing that one can still use ... to get the old
      Message 2 of 6 , Jul 12, 2013
      • 0 Attachment
        On 12-Jul-2013 21:02 +0200, guns wrote:

        > Hello,
        >
        > In the documentation for :jumplist, it is mentioned that
        >
        > You can explicitly add a jump by setting the ' mark.
        >
        > This is true by pressing m' and m` in normal mode, but it does not
        > work by calling the equivalent :call setpos("''", getpos('.')).
        >
        > I am unsure if this is intentional, but if not, this patch
        > addresses this issue (*pos and curwin->w_cursor were compared by
        > identity, not value).
        >
        > I could not find an appropriate test script to append, so I took
        > the liberty of adding test99.in and test99.ok.

        I had noticed that, too, so changing this might break existing plugins
        / macros. On the other hand (providing that one can still use

        :keepjumps call setpos("''", getpos('.'))

        to get the old behavior (can you please confirm?!)), it might be more
        consistent if setpos() behaves exactly like the "m" command.

        -- regards, ingo

        --
        --
        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.
      • guns
        ... Yes, I can confirm :keepjumps preserves the old behavior with this patch. ... Well, I just took a closer look at :help setpos(), and I found: Does not
        Message 3 of 6 , Jul 12, 2013
        • 0 Attachment
          On Fri 12 Jul 2013 at 09:48:33PM +0200, Ingo Karkat wrote:

          > On the other hand (providing that one can still use
          > :keepjumps call setpos("''", getpos('.'))
          >
          > to get the old behavior (can you please confirm?!)),

          Yes, I can confirm :keepjumps preserves the old behavior with this
          patch.

          > it might be more consistent if setpos() behaves exactly like the "m"
          > command.

          Well, I just took a closer look at :help setpos(), and I found:

          Does not change the jumplist.

          Evidently this behavior is intentional to allow setpos() to move the
          cursor without altering the jumplist. This also allows setting the ' and
          ` marks without a corresponding jump entry, which makes sense since the
          previous context marks and jumplist are independent.

          I can see the wisdom in this design (and therefore _rescind my patch_),
          but there is a lack of symmetry: the pcmarks ' and ` can be set
          independent of the jumplist, but the jumplist cannot be changed
          independent of the pcmarks.

          I believe it is worthwhile to add programmatic access to the jumplist.
          For example, calling normal commands is sometimes impossible or
          difficult (like within operator-pending mode mappings), whereas a
          function call is always possible.

          e.g. If I am unable to call ":normal m'", it would be great to have the
          function appendjumplist().

          Any feedback on this is appreciated.

          Thank you,
          Sung Pae
        • Bram Moolenaar
          ... That setpos() does not change the jumplist is intentional. It s a lower level function than using the m command. We can t change this without breaking
          Message 4 of 6 , Jul 13, 2013
          • 0 Attachment
            Sung Pae wrote:

            > In the documentation for :jumplist, it is mentioned that
            >
            > You can explicitly add a jump by setting the ' mark.
            >
            > This is true by pressing m' and m` in normal mode, but it does not work
            > by calling the equivalent :call setpos("''", getpos('.')).
            >
            > I am unsure if this is intentional, but if not, this patch addresses
            > this issue (*pos and curwin->w_cursor were compared by identity, not
            > value).
            >
            > I could not find an appropriate test script to append, so I took the
            > liberty of adding test99.in and test99.ok.

            That setpos() does not change the jumplist is intentional. It's a lower
            level function than using the "m" command. We can't change this without
            breaking scripts.


            --
            I used to wonder about the meaning of life. But I looked it
            up in the dictionary under "L" and there it was - the meaning
            of life. It was less than I expected. - Dogbert

            /// 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.
          • guns
            ... Hi Bram, Sorry for the noise. I saw you clearly wrote this in the documentation after I submitted the patch. I will search more carefully for an answer
            Message 5 of 6 , Jul 13, 2013
            • 0 Attachment
              On Sat 13 Jul 2013 at 05:35:40PM +0200, Bram Moolenaar wrote:

              > That setpos() does not change the jumplist is intentional. It's a lower
              > level function than using the "m" command. We can't change this without
              > breaking scripts.

              Hi Bram,

              Sorry for the noise. I saw you clearly wrote this in the documentation
              after I submitted the patch. I will search more carefully for an answer
              next time.

              However, there is a lack of symmetry: the pcmarks ' and ` can be set
              independently of the jumplist, but the jumplist cannot be changed
              independently of the pcmarks.

              Would you be open to adding a function that appends the jump list so
              that it may be set without invoking a normal command?

              Thank you,
              Sung Pae
            • guns
              ... Thinking further on this, I retract my request for this ability. m is seems to work just fine where I had imagined some difficulty. Sung Pae
              Message 6 of 6 , Jul 14, 2013
              • 0 Attachment
                On Sat 13 Jul 2013 at 03:35:22PM -0500, guns wrote:

                > However, there is a lack of symmetry: the pcmarks ' and ` can be set
                > independently of the jumplist, but the jumplist cannot be changed
                > independently of the pcmarks.

                Thinking further on this, I retract my request for this ability. m' is
                seems to work just fine where I had imagined some difficulty.

                Sung Pae
              Your message has been successfully submitted and would be delivered to recipients shortly.