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

Re: Why is there no :foldupdate?

Expand Messages
  • 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 1 of 5 , Apr 2, 2010
    • 0 Attachment
      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_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
    • 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 2 of 5 , Apr 3, 2010
      • 0 Attachment
        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_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

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