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

Why is there no :foldupdate?

Expand Messages
  • Christian Brabandt
    Hi, sometimes I am using fold expressions to simply hide away unwanted parts. Usually this boils down to ... While this works fine, it is only limited to
    Message 1 of 10 , Mar 31, 2010
      Hi,

      sometimes I am using fold expressions to simply hide away unwanted
      parts. Usually this boils down to
      :set fdm=expr fde=getline(v:lnum)!~getreg('/',1)

      While this works fine, it is only limited to whatever was in register @/
      when this setting was entered. Now this leaves an interesting question:
      When are 'foldexpr' reevaluated (are they at all)? Reading :h fold.txt
      does not mentioned when the fold expressions are reevaluated and folds
      are updated (or I might have missed it).

      Now the obvious cure to this is to reenter the foldexpression. So if I
      am searching for a different term, I need to enter
      :set fde=getline(v:lnum)!~getreg('/',1)
      and the folds will be updated.

      Of course, I could define my own :Foldupdate like this:
      :com! Foldupdate :exe "set fde=".&fde

      But this looks so fundamental, that I am wondering, whether I am the
      only one who is missing :foldupdate. Does anybody else think so? Or am I
      missing something obvious?

      PS: Looking at the source, it does not seem too hard, to define an extra
      :foldupdate command. Does that sound like a reasonable idea? I could
      prepare a patch for this, if there is interest.

      regards,
      Christian

      (Actually, I'd really like an RegisterChanged autocommand event, which
      could trigger an :foldupdate)

      --
      You received this message from the "vim_use" 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

      To unsubscribe, reply using "remove me" as the subject.
    • Paul
      ... You are not the only one. Every once in a while I will somehow see my folds messed up after some serious editing, when I know they are correct, and have to
      Message 2 of 10 , Mar 31, 2010
        On Wed, Mar 31, 2010 at 03:02:41PM +0200, Christian Brabandt wrote:
        >But this looks so fundamental, that I am wondering, whether I am the
        >only one who is missing :foldupdate. Does anybody else think so? Or am I
        >missing something obvious?

        You are not the only one. Every once in a while I will somehow see my folds messed up after some serious editing, when I know they are correct, and have to quit and re-edit the file in order to have them show correctly.

        --

        .

        --
        You received this message from the "vim_use" 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

        To unsubscribe, reply using "remove me" as the subject.
      • Benjamin R. Haskell
        ... I generally just type Ctrl-L to clear and redraw the screen. For most filetypes I prefer fdm=syntax, so maybe something s different with fdm=expr. I
        Message 3 of 10 , Mar 31, 2010
          On Wed, 31 Mar 2010, Paul wrote:

          > On Wed, Mar 31, 2010 at 03:02:41PM +0200, Christian Brabandt wrote:
          > > But this looks so fundamental, that I am wondering, whether I am the
          > > only one who is missing :foldupdate. Does anybody else think so? Or
          > > am I missing something obvious?
          >
          > You are not the only one. Every once in a while I will somehow see my
          > folds messed up after some serious editing, when I know they are
          > correct, and have to quit and re-edit the file in order to have them
          > show correctly.

          I generally just type Ctrl-L to clear and redraw the screen. For most
          filetypes I prefer fdm=syntax, so maybe something's different with
          fdm=expr.

          I notice the improper folds most frequently when I've just added another
          branch to a conditional (e.g. turning something with the structure
          if(1){}else{}
          into
          if(1){}elsif(2){}else{}
          ) but I can't seem to come up with a good minimal case. I'll try to do
          that next time I notice the problem.


          In case they affect anything, I also still have the following mappings
          in place:

          aug NoInsertFolding
          au!
          au InsertEnter * let b:oldfdm = &l:fdm | setlocal fdm=manual
          au InsertLeave * let &l:fdm = b:oldfdm
          aug END

          They have their own problems (referenced in another thread), but are
          better than the madness of folds changing mid-insert.

          --
          Best,
          Ben

          --
          You received this message from the "vim_use" 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

          To unsubscribe, reply using "remove me" as the subject.
        • Christian Brabandt
          ... Ctrl-L does not update folds. (Usually I don t use folding. Only when searching for something I find foldmethod=expr convenient). ... I remember that
          Message 4 of 10 , Mar 31, 2010
            On Wed, March 31, 2010 5:15 pm, Benjamin R. Haskell wrote:
            > On Wed, 31 Mar 2010, Paul wrote:
            >> On Wed, Mar 31, 2010 at 03:02:41PM +0200, Christian Brabandt wrote:
            >> > But this looks so fundamental, that I am wondering, whether I am the
            >> > only one who is missing :foldupdate. Does anybody else think so? Or
            >> > am I missing something obvious?
            >>
            >> You are not the only one. Every once in a while I will somehow see my
            >> folds messed up after some serious editing, when I know they are
            >> correct, and have to quit and re-edit the file in order to have them
            >> show correctly.
            >
            > I generally just type Ctrl-L to clear and redraw the screen. For most
            > filetypes I prefer fdm=syntax, so maybe something's different with
            > fdm=expr.

            Ctrl-L does not update folds.
            (Usually I don't use folding. Only when searching for something
            I find foldmethod=expr convenient).

            > I notice the improper folds most frequently when I've just added another
            > branch to a conditional (e.g. turning something with the structure
            > if(1){}else{}
            > into
            > if(1){}elsif(2){}else{}
            > ) but I can't seem to come up with a good minimal case. I'll try to do
            > that next time I notice the problem.

            I remember that fdm=syntax is mentioned several times in todo.txt.

            regards,
            Christian

            --
            You received this message from the "vim_use" 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

            To unsubscribe, reply using "remove me" as the subject.
          • Benjamin R. Haskell
            ... Are you sure? Ctrl-L appears to just call redraw_later, and I didn t fully trace the call tree, but redraw_later seems to end up calling
            Message 5 of 10 , Mar 31, 2010
              On Wed, 31 Mar 2010, Christian Brabandt wrote:

              > On Wed, March 31, 2010 5:15 pm, Benjamin R. Haskell wrote:
              > > On Wed, 31 Mar 2010, Paul wrote:
              > >> On Wed, Mar 31, 2010 at 03:02:41PM +0200, Christian Brabandt wrote:
              > >> > But this looks so fundamental, that I am wondering, whether I am
              > >> > the only one who is missing :foldupdate. Does anybody else think
              > >> > so? Or am I missing something obvious?
              > >>
              > >> You are not the only one. Every once in a while I will somehow see
              > >> my folds messed up after some serious editing, when I know they are
              > >> correct, and have to quit and re-edit the file in order to have
              > >> them show correctly.
              > >
              > > I generally just type Ctrl-L to clear and redraw the screen. For
              > > most filetypes I prefer fdm=syntax, so maybe something's different
              > > with fdm=expr.
              >
              > Ctrl-L does not update folds.

              Are you sure? Ctrl-L appears to just call redraw_later, and I didn't
              fully trace the call tree, but redraw_later seems to end up calling
              FOR_ALL_WINDOWS...redraw_win_later, which would end up calling
              redrawWinline (which does something with folds), eventually... yes?

              All I know is that every time I've noticed an improper fold, I've hit
              Ctrl-L to correct the problem.

              But again, I don't use fdm=expr. So, maybe whatever mechanism marks a
              fold as invalid doesn't use the same logic when fdm=syntax.

              --
              Best,
              Ben

              --
              You received this message from the "vim_use" 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

              To unsubscribe, reply using "remove me" as the subject.
            • Christian Brabandt
              (fullquote, because copying vim_dev) ... Ok, here is a patch, that implements :foldupdate as ex command and zU as normal mode command. Here is the testcase: go
              Message 6 of 10 , Mar 31, 2010
                (fullquote, because copying vim_dev)

                On Mi, 31 Mär 2010, Christian Brabandt wrote:

                > Hi,
                >
                > sometimes I am using fold expressions to simply hide away unwanted
                > parts. Usually this boils down to
                > :set fdm=expr fde=getline(v:lnum)!~getreg('/',1)
                >
                > While this works fine, it is only limited to whatever was in register @/
                > when this setting was entered. Now this leaves an interesting question:
                > When are 'foldexpr' reevaluated (are they at all)? Reading :h fold.txt
                > does not mentioned when the fold expressions are reevaluated and folds
                > are updated (or I might have missed it).
                >
                > Now the obvious cure to this is to reenter the foldexpression. So if I
                > am searching for a different term, I need to enter
                > :set fde=getline(v:lnum)!~getreg('/',1)
                > and the folds will be updated.
                >
                > Of course, I could define my own :Foldupdate like this:
                > :com! Foldupdate :exe "set fde=".&fde
                >
                > But this looks so fundamental, that I am wondering, whether I am the
                > only one who is missing :foldupdate. Does anybody else think so? Or am I
                > missing something obvious?
                >
                > PS: Looking at the source, it does not seem too hard, to define an extra
                > :foldupdate command. Does that sound like a reasonable idea? I could
                > prepare a patch for this, if there is interest.
                >
                > regards,
                > Christian
                >
                > (Actually, I'd really like an RegisterChanged autocommand event, which
                > could trigger an :foldupdate)

                Ok, here is a patch, that implements :foldupdate as ex command and zU as
                normal mode command.

                Here is the testcase:
                go to the vim-Src directory and execute the attached vim-script:

                chrisbra t41:~/vim/src [1296]% ./vim -u NONE -N -S foldupdate.vim eval.c

                Note, how the folding will be wrong, after the second search command
                (and I have found no way to refresh the folding. zx and zX do not work,
                though its description led me believe it could have. Well actually I
                found one way: filtering the whole buffer through cat will also update
                the folding)

                When recompiling vim with the patch, the folding will be updated, when
                :foldupdate is called.

                regards,
                Christian

                --
                You received this message from the "vim_use" 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

                To unsubscribe, reply using "remove me" as the subject.
              • Bram Moolenaar
                ... Thanks! Feedback welcome. One remark: in the help, add a bit more information about when this would be needed, why the folds are not updated
                Message 7 of 10 , Apr 1, 2010
                  Christian Brabandt wrote:

                  > > sometimes I am using fold expressions to simply hide away unwanted
                  > > parts. Usually this boils down to
                  > > :set fdm=expr fde=getline(v:lnum)!~getreg('/',1)
                  > >
                  > > While this works fine, it is only limited to whatever was in register @/
                  > > when this setting was entered. Now this leaves an interesting question:
                  > > When are 'foldexpr' reevaluated (are they at all)? Reading :h fold.txt
                  > > does not mentioned when the fold expressions are reevaluated and folds
                  > > are updated (or I might have missed it).
                  > >
                  > > Now the obvious cure to this is to reenter the foldexpression. So if I
                  > > am searching for a different term, I need to enter
                  > > :set fde=getline(v:lnum)!~getreg('/',1)
                  > > and the folds will be updated.
                  > >
                  > > Of course, I could define my own :Foldupdate like this:
                  > > :com! Foldupdate :exe "set fde=".&fde
                  > >
                  > > But this looks so fundamental, that I am wondering, whether I am the
                  > > only one who is missing :foldupdate. Does anybody else think so? Or am I
                  > > missing something obvious?
                  > >
                  > > PS: Looking at the source, it does not seem too hard, to define an extra
                  > > :foldupdate command. Does that sound like a reasonable idea? I could
                  > > prepare a patch for this, if there is interest.
                  > >
                  > > regards,
                  > > Christian
                  > >
                  > > (Actually, I'd really like an RegisterChanged autocommand event, which
                  > > could trigger an :foldupdate)
                  >
                  > Ok, here is a patch, that implements :foldupdate as ex command and zU as
                  > normal mode command.
                  >
                  > Here is the testcase:
                  > go to the vim-Src directory and execute the attached vim-script:
                  >
                  > chrisbra t41:~/vim/src [1296]% ./vim -u NONE -N -S foldupdate.vim eval.c
                  >
                  > Note, how the folding will be wrong, after the second search command
                  > (and I have found no way to refresh the folding. zx and zX do not work,
                  > though its description led me believe it could have. Well actually I
                  > found one way: filtering the whole buffer through cat will also update
                  > the folding)
                  >
                  > When recompiling vim with the patch, the folding will be updated, when
                  > :foldupdate is called.

                  Thanks! Feedback welcome.

                  One remark: in the help, add a bit more information about when this would
                  be needed, why the folds are not updated automatically.

                  --
                  BEDEVERE: Stand by for attack!!
                  [CUT TO enormous army forming up. Trebuchets, rows of PIKEMEN, siege
                  towers, pennants flying, shouts of "Stand by for attack!" Traditional
                  army build-up shots. The shouts echo across the ranks of the army.
                  We see various groups reacting, and stirring themselves in readiness.]
                  ARTHUR: Who are they?
                  BEDEVERE: Oh, just some friends!
                  "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

                  /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
                  /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
                  \\\ 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_use" 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

                  To unsubscribe, reply using "remove me" as the subject.
                • Christian Brabandt
                  Hi Bram! ... Attached is an updated patch. Is this better? regards, Christian -- You received this message from the vim_use maillist. Do not top-post! Type
                  Message 8 of 10 , Apr 1, 2010
                    Hi Bram!

                    On Do, 01 Apr 2010, Bram Moolenaar wrote:

                    > One remark: in the help, add a bit more information about when this would
                    > be needed, why the folds are not updated automatically.

                    Attached is an updated patch. Is this better?

                    regards,
                    Christian

                    --
                    You received this message from the "vim_use" 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

                    To unsubscribe, reply using "remove me" as the subject.
                  • Tony Mechelynck
                    ... Doesn t this patch duplicate the already existing zx command? If it does, and you can t remember it, I suggest the following ;-) ... Best regards, Tony. --
                    Message 9 of 10 , Apr 2, 2010
                      On 31/03/10 23:27, Christian Brabandt wrote:
                      > (fullquote, because copying vim_dev)
                      >
                      > On Mi, 31 Mär 2010, Christian Brabandt wrote:
                      >
                      >> Hi,
                      >>
                      >> sometimes I am using fold expressions to simply hide away unwanted
                      >> parts. Usually this boils down to
                      >> :set fdm=expr fde=getline(v:lnum)!~getreg('/',1)
                      >>
                      >> While this works fine, it is only limited to whatever was in register @/
                      >> when this setting was entered. Now this leaves an interesting question:
                      >> When are 'foldexpr' reevaluated (are they at all)? Reading :h fold.txt
                      >> does not mentioned when the fold expressions are reevaluated and folds
                      >> are updated (or I might have missed it).
                      >>
                      >> Now the obvious cure to this is to reenter the foldexpression. So if I
                      >> am searching for a different term, I need to enter
                      >> :set fde=getline(v:lnum)!~getreg('/',1)
                      >> and the folds will be updated.
                      >>
                      >> Of course, I could define my own :Foldupdate like this:
                      >> :com! Foldupdate :exe "set fde=".&fde
                      >>
                      >> But this looks so fundamental, that I am wondering, whether I am the
                      >> only one who is missing :foldupdate. Does anybody else think so? Or am I
                      >> missing something obvious?
                      >>
                      >> PS: Looking at the source, it does not seem too hard, to define an extra
                      >> :foldupdate command. Does that sound like a reasonable idea? I could
                      >> prepare a patch for this, if there is interest.
                      >>
                      >> regards,
                      >> Christian
                      >>
                      >> (Actually, I'd really like an RegisterChanged autocommand event, which
                      >> could trigger an :foldupdate)
                      >
                      > Ok, here is a patch, that implements :foldupdate as ex command and zU as
                      > normal mode command.
                      >
                      > Here is the testcase:
                      > go to the vim-Src directory and execute the attached vim-script:
                      >
                      > chrisbra t41:~/vim/src [1296]% ./vim -u NONE -N -S foldupdate.vim eval.c
                      >
                      > Note, how the folding will be wrong, after the second search command
                      > (and I have found no way to refresh the folding. zx and zX do not work,
                      > though its description led me believe it could have. Well actually I
                      > found one way: filtering the whole buffer through cat will also update
                      > the folding)
                      >
                      > When recompiling vim with the patch, the folding will be updated, when
                      > :foldupdate is called.
                      >
                      > regards,
                      > Christian
                      >

                      Doesn't this patch duplicate the already existing zx command?

                      If it does, and you can't remember it, I suggest the following ;-)

                      :command -nargs=0 -bar Foldupdate normal zx


                      Best regards,
                      Tony.
                      --
                      Any clod can have the facts, but having an opinion is an art.
                      -- Charles McCabe

                      --
                      You received this message from the "vim_use" 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

                      To unsubscribe, reply using "remove me" as the subject.
                    • Christian Brabandt
                      Hi Tony! ... Please read again, what I already wrote ;) Should zx or zX maybe be changed to update the folds? regards, Christian -- You received this message
                      Message 10 of 10 , Apr 3, 2010
                        Hi Tony!

                        On Sa, 03 Apr 2010, Tony Mechelynck wrote:

                        > On 31/03/10 23:27, Christian Brabandt wrote:
                        >> Note, how the folding will be wrong, after the second search command
                        >> (and I have found no way to refresh the folding. zx and zX do not work,
                        >> though its description led me believe it could have. Well actually I
                        >> found one way: filtering the whole buffer through cat will also update
                        >> the folding)

                        > Doesn't this patch duplicate the already existing zx command?

                        Please read again, what I already wrote ;)

                        Should zx or zX maybe be changed to update the folds?

                        regards,
                        Christian

                        --
                        You received this message from the "vim_use" 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

                        To unsubscribe, reply using "remove me" as the subject.
                      Your message has been successfully submitted and would be delivered to recipients shortly.