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

[PATCH] :diffoff should not change settings for non-diff windows

Expand Messages
  • Lech Lorens
    The solution seems so easy, that I suspect that I might have fixed behaviour that is actually desired. However, for me it always seemed that :diffoff should
    Message 1 of 13 , Mar 3, 2009
    • 0 Attachment
      The solution seems so easy, that I suspect that I might have fixed
      behaviour that is actually desired. However, for me it always seemed
      that :diffoff should only act on windows, that have 'diff' set, not ALL
      windows in the current tab. The attached patch makes Vim behave so.

      --
      Cheers,
      Lech

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_dev" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Bram Moolenaar
      ... The current behavior is intentional. A user may first do :set nodiff and discover that other things were not reset. Then :diffoff should get rid of
      Message 2 of 13 , Mar 3, 2009
      • 0 Attachment
        Lech Lorens wrote:

        > The solution seems so easy, that I suspect that I might have fixed
        > behaviour that is actually desired. However, for me it always seemed
        > that :diffoff should only act on windows, that have 'diff' set, not ALL
        > windows in the current tab. The attached patch makes Vim behave so.

        The current behavior is intentional. A user may first do ":set nodiff"
        and discover that other things were not reset. Then ":diffoff" should
        get rid of the rest.

        However, perhaps it should do this unconditionally for the current
        window only. For other windows it makes more sense to check the 'diff'
        option.

        > - if (wp == curwin || eap->forceit)
        > + if (wp == curwin || (wp->w_p_diff && eap->forceit))

        How about that?


        --
        hundred-and-one symptoms of being an internet addict:
        160. You get in the elevator and double-click the button for the floor
        you want.

        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
        /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
        \\\ download, build and distribute -- http://www.A-A-P.org ///
        \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_dev" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • Lech Lorens
        ... Perfectly fine with me - I hardly ever use :diffoff without !, anyway. -- Cheers, Lech --~--~---------~--~----~------------~-------~--~----~ You received
        Message 3 of 13 , Mar 5, 2009
        • 0 Attachment
          04-03-2009 Bram Moolenaar <Bram@...>:
          >
          > However, perhaps it should do this unconditionally for the current
          > window only. For other windows it makes more sense to check the 'diff'
          > option.
          >
          > > - if (wp == curwin || eap->forceit)
          > > + if (wp == curwin || (wp->w_p_diff && eap->forceit))
          >
          > How about that?

          Perfectly fine with me - I hardly ever use :diffoff without !, anyway.

          --
          Cheers,
          Lech

          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_dev" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • Markus Heidelberg
          ... Is there a reason to not support the corresponding :diffthis! command? For consistency it seems like a good idea, instead of using two different ways
          Message 4 of 13 , Mar 5, 2009
          • 0 Attachment
            Lech Lorens, 05.03.2009:
            > Perfectly fine with me - I hardly ever use :diffoff without !, anyway.

            Is there a reason to not support the corresponding :diffthis! command?
            For consistency it seems like a good idea, instead of using two
            different ways ":windo diffthis" and ":diffoff!". Furthermore :windo can
            move the cursor into another window, which is normally not desired.

            --- >8 ---

            Add support for :diffthis! for setting the diffmode in all windows in
            the current tab page.

            ---
            runtime/doc/diff.txt | 4 +++-
            src/diff.c | 12 +++++++++---
            src/ex_cmds.h | 2 +-
            3 files changed, 13 insertions(+), 5 deletions(-)

            diff --git a/runtime/doc/diff.txt b/runtime/doc/diff.txt
            index 3f55c30..270a1bd 100644
            --- a/runtime/doc/diff.txt
            +++ b/runtime/doc/diff.txt
            @@ -88,8 +88,10 @@ While already in Vim you can start diff mode in three ways.
            Also see 'diffexpr'.

            *:difft* *:diffthis*
            -:diffthis Make the current window part of the diff windows. This sets
            +:diffthis[!] Make the current window part of the diff windows. This sets
            the options like for "vimdiff".
            + When the [!] is included set the diff mode for all windows in
            + the current tab page.

            :diffpatch {patchfile} *:diffp* *:diffpatch*
            Use the current buffer, patch it with the diff found in
            diff --git a/src/diff.c b/src/diff.c
            index c20d095..04aee4b 100644
            --- a/src/diff.c
            +++ b/src/diff.c
            @@ -1087,15 +1087,21 @@ ex_diffsplit(eap)
            }

            /*
            - * Set options to show difs for the current window.
            + * Set options to show diffs for the current window.
            */
            /*ARGSUSED*/
            void
            ex_diffthis(eap)
            exarg_T *eap;
            {
            - /* Set 'diff', 'scrollbind' on and 'wrap' off. */
            - diff_win_options(curwin, TRUE);
            + win_T *wp;
            +
            + for (wp = firstwin; wp != NULL; wp = wp->w_next)
            + {
            + if (wp == curwin || eap->forceit)
            + /* Set 'diff', 'scrollbind' on and 'wrap' off. */
            + diff_win_options(wp, TRUE);
            + }
            }

            /*
            diff --git a/src/ex_cmds.h b/src/ex_cmds.h
            index 4916750..08aa0d1 100644
            --- a/src/ex_cmds.h
            +++ b/src/ex_cmds.h
            @@ -316,7 +316,7 @@ EX(CMD_diffput, "diffput", ex_diffgetput,
            EX(CMD_diffsplit, "diffsplit", ex_diffsplit,
            EXTRA|FILE1|TRLBAR),
            EX(CMD_diffthis, "diffthis", ex_diffthis,
            - TRLBAR),
            + BANG|TRLBAR),
            EX(CMD_digraphs, "digraphs", ex_digraphs,
            EXTRA|TRLBAR|CMDWIN),
            EX(CMD_djump, "djump", ex_findpat,
            --
            1.6.2.15.g9514d




            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_dev" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          • Bram Moolenaar
            ... Makes sense. But it should skip special windows: help, quickfix, preview, etc. -- Did you ever see a Hit any key to continue message in a music piece?
            Message 5 of 13 , Mar 5, 2009
            • 0 Attachment
              Markus Heidelberg wrote:

              > Lech Lorens, 05.03.2009:
              > > Perfectly fine with me - I hardly ever use :diffoff without !, anyway.
              >
              > Is there a reason to not support the corresponding :diffthis! command?
              > For consistency it seems like a good idea, instead of using two
              > different ways ":windo diffthis" and ":diffoff!". Furthermore :windo can
              > move the cursor into another window, which is normally not desired.
              >
              > --- >8 ---
              >
              > Add support for :diffthis! for setting the diffmode in all windows in
              > the current tab page.

              Makes sense. But it should skip "special" windows: help, quickfix,
              preview, etc.


              --
              Did you ever see a "Hit any key to continue" message in a music piece?

              /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
              /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
              \\\ download, build and distribute -- http://www.A-A-P.org ///
              \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

              --~--~---------~--~----~------------~-------~--~----~
              You received this message from the "vim_dev" maillist.
              For more information, visit http://www.vim.org/maillist.php
              -~----------~----~----~----~------~----~------~--~---
            • Markus Heidelberg
              ... Sure, will do. What do you think, should the :diffthis! command set a special window into diffmode, if it is the current window or should it never adjust
              Message 6 of 13 , Mar 6, 2009
              • 0 Attachment
                Bram Moolenaar, 06.03.2009:
                >
                > Markus Heidelberg wrote:
                >
                > > Lech Lorens, 05.03.2009:
                > > > Perfectly fine with me - I hardly ever use :diffoff without !, anyway.
                > >
                > > Is there a reason to not support the corresponding :diffthis! command?
                > > For consistency it seems like a good idea, instead of using two
                > > different ways ":windo diffthis" and ":diffoff!". Furthermore :windo can
                > > move the cursor into another window, which is normally not desired.
                > >
                > > --- >8 ---
                > >
                > > Add support for :diffthis! for setting the diffmode in all windows in
                > > the current tab page.
                >
                > Makes sense. But it should skip "special" windows: help, quickfix,
                > preview, etc.

                Sure, will do.

                What do you think, should the :diffthis! command set a special window
                into diffmode, if it is the current window or should it never adjust
                special windows?
                I guess the former solution would be more consistent, since :diffthis
                sets the current window into diffmode regardless of it being a special
                window or not.

                Markus


                --~--~---------~--~----~------------~-------~--~----~
                You received this message from the "vim_dev" maillist.
                For more information, visit http://www.vim.org/maillist.php
                -~----------~----~----~----~------~----~------~--~---
              • Ben Fritz
                ... I think, if a user executes :diffthis! in a special window, they probably intend to diff the special window. If they execute :diffthis! in a different
                Message 7 of 13 , Mar 6, 2009
                • 0 Attachment
                  On Mar 6, 3:41 am, Markus Heidelberg <markus.heidelb...@...> wrote:
                  >
                  > What do you think, should the :diffthis! command set a special window
                  > into diffmode, if it is the current window or should it never adjust
                  > special windows?

                  I think, if a user executes :diffthis! in a special window, they
                  probably intend to diff the special window.

                  If they execute :diffthis! in a different window, and a special window
                  is also up, they may have forgotten the fact that the special window
                  is there.

                  I would lean toward setting diff mode on the current window always,
                  but only setting it on other windows if they are not special.

                  The command window should never be in diff mode however.
                  --~--~---------~--~----~------------~-------~--~----~
                  You received this message from the "vim_dev" maillist.
                  For more information, visit http://www.vim.org/maillist.php
                  -~----------~----~----~----~------~----~------~--~---
                • Markus Heidelberg
                  ... help, quickfix and preview are handled now. At the bottom of :h windows there are furthermore directory, scratch and unlisted. I m not quite sure how to
                  Message 8 of 13 , Mar 6, 2009
                  • 0 Attachment
                    Ben Fritz, 06.03.2009:
                    >
                    > On Mar 6, 3:41 am, Markus Heidelberg <markus.heidelb...@...> wrote:
                    > >
                    > > What do you think, should the :diffthis! command set a special window
                    > > into diffmode, if it is the current window or should it never adjust
                    > > special windows?
                    >
                    > I think, if a user executes :diffthis! in a special window, they
                    > probably intend to diff the special window.
                    >
                    > If they execute :diffthis! in a different window, and a special window
                    > is also up, they may have forgotten the fact that the special window
                    > is there.
                    >
                    > I would lean toward setting diff mode on the current window always,
                    > but only setting it on other windows if they are not special.

                    help, quickfix and preview are handled now. At the bottom of ":h
                    windows" there are furthermore directory, scratch and unlisted. I'm not
                    quite sure how to handle them. I think 'unlisted' doesn't have to be
                    handled. I have heard about 'scratch' but I can't remember for what to
                    use it. For 'directory' I get buftype=nofile when doing ":new .",
                    "nowrite" in the documentation doesn't seem to be completely correct.

                    Is it sufficient to simply treat each buftype!="" as special? But then
                    'buftype' only exists for +quickfix, but I guess netrw.vim also works
                    without this feature.

                    > The command window should never be in diff mode however.

                    The command window is restricted in possible commands anyway. And you
                    cannot escape.

                    Markus


                    --~--~---------~--~----~------------~-------~--~----~
                    You received this message from the "vim_dev" maillist.
                    For more information, visit http://www.vim.org/maillist.php
                    -~----------~----~----~----~------~----~------~--~---
                  • Bram Moolenaar
                    ... Yes, if you do :diffthis or :diffthis! then the current window should always go to diff mode. But :diffthis! should only include other windows that are
                    Message 9 of 13 , Mar 8, 2009
                    • 0 Attachment
                      Markus Heidelberg wrote:

                      > Bram Moolenaar, 06.03.2009:
                      > >
                      > > Markus Heidelberg wrote:
                      > >
                      > > > Lech Lorens, 05.03.2009:
                      > > > > Perfectly fine with me - I hardly ever use :diffoff without !, anyway.
                      > > >
                      > > > Is there a reason to not support the corresponding :diffthis! command?
                      > > > For consistency it seems like a good idea, instead of using two
                      > > > different ways ":windo diffthis" and ":diffoff!". Furthermore :windo can
                      > > > move the cursor into another window, which is normally not desired.
                      > > >
                      > > > --- >8 ---
                      > > >
                      > > > Add support for :diffthis! for setting the diffmode in all windows in
                      > > > the current tab page.
                      > >
                      > > Makes sense. But it should skip "special" windows: help, quickfix,
                      > > preview, etc.
                      >
                      > Sure, will do.
                      >
                      > What do you think, should the :diffthis! command set a special window
                      > into diffmode, if it is the current window or should it never adjust
                      > special windows?
                      > I guess the former solution would be more consistent, since :diffthis
                      > sets the current window into diffmode regardless of it being a special
                      > window or not.

                      Yes, if you do :diffthis or :diffthis! then the current window should
                      always go to diff mode. But ":diffthis!" should only include other
                      windows that are "normal" to avoid trouble.

                      It's perhaps a bit strange to use ":diffthis!" to start diff mode in
                      other windows. ":diffall" would be more obvious. It's not symmetric
                      with ":diffoff" vs ":diffoff!", but that one doesn't say "this".

                      What do you all think about using ":diffall" instead?

                      --
                      The CIA drives around in cars with the "Intel inside" logo.

                      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
                      /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
                      \\\ download, build and distribute -- http://www.A-A-P.org ///
                      \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

                      --~--~---------~--~----~------------~-------~--~----~
                      You received this message from the "vim_dev" maillist.
                      For more information, visit http://www.vim.org/maillist.php
                      -~----------~----~----~----~------~----~------~--~---
                    • Markus Heidelberg
                      ... That s for sure! ... Or what about :diffon[!] ? ... symmetry with :diffoff[!] in terms of invocation and spelling. Maybe this could be declared as the
                      Message 10 of 13 , Mar 8, 2009
                      • 0 Attachment
                        Bram Moolenaar, 08.03.2009:
                        >
                        > Markus Heidelberg wrote:
                        >
                        > > Bram Moolenaar, 06.03.2009:
                        > > >
                        > > > Markus Heidelberg wrote:
                        > > >
                        > > > > Lech Lorens, 05.03.2009:
                        > > > > > Perfectly fine with me - I hardly ever use :diffoff without !, anyway.
                        > > > >
                        > > > > Is there a reason to not support the corresponding :diffthis! command?
                        > > > > For consistency it seems like a good idea, instead of using two
                        > > > > different ways ":windo diffthis" and ":diffoff!". Furthermore :windo can
                        > > > > move the cursor into another window, which is normally not desired.
                        > > > >
                        > > > > --- >8 ---
                        > > > >
                        > > > > Add support for :diffthis! for setting the diffmode in all windows in
                        > > > > the current tab page.
                        > > >
                        > > > Makes sense. But it should skip "special" windows: help, quickfix,
                        > > > preview, etc.
                        > >
                        > > Sure, will do.
                        > >
                        > > What do you think, should the :diffthis! command set a special window
                        > > into diffmode, if it is the current window or should it never adjust
                        > > special windows?
                        > > I guess the former solution would be more consistent, since :diffthis
                        > > sets the current window into diffmode regardless of it being a special
                        > > window or not.
                        >
                        > Yes, if you do :diffthis or :diffthis! then the current window should
                        > always go to diff mode. But ":diffthis!" should only include other
                        > windows that are "normal" to avoid trouble.
                        >
                        > It's perhaps a bit strange to use ":diffthis!" to start diff mode in
                        > other windows.

                        That's for sure!

                        > ":diffall" would be more obvious. It's not symmetric
                        > with ":diffoff" vs ":diffoff!", but that one doesn't say "this".
                        >
                        > What do you all think about using ":diffall" instead?

                        Or what about :diffon[!] ?
                        :diffon would be a synonym for :diffthis then and there would be
                        symmetry with :diffoff[!] in terms of invocation and spelling.
                        Maybe this could be declared as the preferred method then.

                        Indeed I already wondered, why it was called :diffthis instead of
                        :diffon, since there was a :diffoff. And then I read that :diffoff was
                        introduced a major version later than :diffthis. I guess if they were
                        introduced at the same time, it wouldn't have been called :diffthis.

                        Markus


                        --~--~---------~--~----~------------~-------~--~----~
                        You received this message from the "vim_dev" maillist.
                        For more information, visit http://www.vim.org/maillist.php
                        -~----------~----~----~----~------~----~------~--~---
                      • Andy Wokula
                        ... I d prefer :diffall over :diffon! : When there are three commands for diffing, it will be clearer what :diffall means. Later :diffall! can be added
                        Message 11 of 13 , Mar 8, 2009
                        • 0 Attachment
                          Markus Heidelberg schrieb:
                          > Bram Moolenaar, 08.03.2009:
                          >> Markus Heidelberg wrote:
                          >>
                          >>> Bram Moolenaar, 06.03.2009:
                          >>>> Markus Heidelberg wrote:
                          >>>>
                          >>>>> Lech Lorens, 05.03.2009:
                          >>>>>> Perfectly fine with me - I hardly ever use :diffoff without !, anyway.
                          >>>>> Is there a reason to not support the corresponding :diffthis! command?
                          >>>>> For consistency it seems like a good idea, instead of using two
                          >>>>> different ways ":windo diffthis" and ":diffoff!". Furthermore :windo can
                          >>>>> move the cursor into another window, which is normally not desired.
                          >>>>>
                          >>>>> --- >8 ---
                          >>>>>
                          >>>>> Add support for :diffthis! for setting the diffmode in all windows in
                          >>>>> the current tab page.
                          >>>> Makes sense. But it should skip "special" windows: help, quickfix,
                          >>>> preview, etc.
                          >>> Sure, will do.
                          >>>
                          >>> What do you think, should the :diffthis! command set a special window
                          >>> into diffmode, if it is the current window or should it never adjust
                          >>> special windows?
                          >>> I guess the former solution would be more consistent, since :diffthis
                          >>> sets the current window into diffmode regardless of it being a special
                          >>> window or not.
                          >>>
                          >> Yes, if you do :diffthis or :diffthis! then the current window should
                          >> always go to diff mode. But ":diffthis!" should only include other
                          >> windows that are "normal" to avoid trouble.
                          >>
                          >> It's perhaps a bit strange to use ":diffthis!" to start diff mode in
                          >> other windows.
                          >
                          > That's for sure!
                          >
                          >> ":diffall" would be more obvious. It's not symmetric
                          >> with ":diffoff" vs ":diffoff!", but that one doesn't say "this".
                          >>
                          >> What do you all think about using ":diffall" instead?
                          >
                          > Or what about :diffon[!] ?
                          > :diffon would be a synonym for :diffthis then and there would be
                          > symmetry with :diffoff[!] in terms of invocation and spelling.
                          > Maybe this could be declared as the preferred method then.
                          >
                          > Indeed I already wondered, why it was called :diffthis instead of
                          > :diffon, since there was a :diffoff. And then I read that :diffoff was
                          > introduced a major version later than :diffthis. I guess if they were
                          > introduced at the same time, it wouldn't have been called :diffthis.
                          >
                          > Markus

                          I'd prefer ":diffall" over ":diffon!":

                          When there are three commands for diffing, it will be clearer what
                          ":diffall" means.

                          Later ":diffall!" can be added to really include all windows in the
                          diff.

                          ":diffon!" and ":diffoff!" wouldn't be exact opposites: if other windows
                          are special, ":diffoff!" may include them, unlike ":diffon!".

                          --
                          Andy


                          --~--~---------~--~----~------------~-------~--~----~
                          You received this message from the "vim_dev" maillist.
                          For more information, visit http://www.vim.org/maillist.php
                          -~----------~----~----~----~------~----~------~--~---
                        • John Beckett
                          ... There is already quite a bit of history in Vim, so I would prefer to NOT introduce a new command. The following looks logical to me: Go to window 1 ...
                          Message 12 of 13 , Mar 8, 2009
                          • 0 Attachment
                            Bram Moolenaar wrote:
                            > It's perhaps a bit strange to use ":diffthis!" to start diff
                            > mode in other windows. ":diffall" would be more obvious.
                            > It's not symmetric with ":diffoff" vs ":diffoff!", but that
                            > one doesn't say "this".
                            >
                            > What do you all think about using ":diffall" instead?

                            There is already quite a bit of "history" in Vim, so I would prefer to
                            NOT introduce a new command. The following looks logical to me:

                            " Go to window 1
                            :diffthis
                            " Go to window 2
                            :diffthis

                            " Remove diff from all visible windows
                            :diffoff!

                            " Apply diff to all visible (normal) windows
                            :diffthis!

                            John


                            --~--~---------~--~----~------------~-------~--~----~
                            You received this message from the "vim_dev" maillist.
                            For more information, visit http://www.vim.org/maillist.php
                            -~----------~----~----~----~------~----~------~--~---
                          • Markus Heidelberg
                            ... If :diffthis wouldn t yet exist, I d definetly prefer :diffon[!] and ... is probably a bit confusing, since we would end up with 3 commands (this|off|all)
                            Message 13 of 13 , Mar 13, 2009
                            • 0 Attachment
                              John Beckett, 09.03.2009:
                              >
                              > Bram Moolenaar wrote:
                              > > It's perhaps a bit strange to use ":diffthis!" to start diff
                              > > mode in other windows. ":diffall" would be more obvious.
                              > > It's not symmetric with ":diffoff" vs ":diffoff!", but that
                              > > one doesn't say "this".
                              > >
                              > > What do you all think about using ":diffall" instead?
                              >
                              > There is already quite a bit of "history" in Vim, so I would prefer to
                              > NOT introduce a new command.

                              If :diffthis wouldn't yet exist, I'd definetly prefer :diffon[!] and
                              :diffoff[!]. But now I also prefer :diffthis!. A new command :diffall
                              is probably a bit confusing, since we would end up with 3 commands
                              (this|off|all) for 2 (or 4) actions (diff on/off).

                              I just though, if we treat :diffthis as "diff this window" and
                              :diffthis! as "diff this tab", then the "this" in the latter command
                              doesn't seem so linguistic strange any more.

                              > The following looks logical to me:
                              >
                              > " Go to window 1
                              > :diffthis
                              > " Go to window 2
                              > :diffthis
                              >
                              > " Remove diff from all visible windows
                              > :diffoff!
                              >
                              > " Apply diff to all visible (normal) windows
                              > :diffthis!

                              This is my preferred solution, too.

                              Markus


                              --~--~---------~--~----~------------~-------~--~----~
                              You received this message from the "vim_dev" maillist.
                              For more information, visit http://www.vim.org/maillist.php
                              -~----------~----~----~----~------~----~------~--~---
                            Your message has been successfully submitted and would be delivered to recipients shortly.