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

Re: How can I force no undo dunring a function call?

Expand Messages
  • Benji Fisher
    ... It works as expected for me. Maybe the problem is somewhere else. I tried fun! UndoTest() setlocal ul=-1 put= testing undolevels setlocal ul=1000 endfun
    Message 1 of 2 , Jul 31, 2002
    View Source
    • 0 Attachment
      Mario Schweigler wrote:
      >
      > Hi,
      >
      > I want the following: When I call a function, I would like that
      > afterwards the undo buffer is empty, i.e. I can't undo the stuff that
      > the function has changed.
      >
      > But if I change something manually later, it must be undoable just like
      > normal.
      >
      > I tried
      >
      > :let save_ul = &undolevels
      > :setlocal undolevels=-1
      >
      > at the beginning of the function and
      >
      > :exe 'setlocal undolevels=' . save_ul
      >
      > at the end of the function. But it does not work! If I press u after
      > calling the function it still undoes the function's changes.

      It works as expected for me. Maybe the problem is somewhere else. I tried

      fun! UndoTest()
      setlocal ul=-1
      put='testing undolevels'
      setlocal ul=1000
      endfun

      After :call UndoTest() I get an extra line, and "u" does not make it go away.
      BTW, I used :setlocal because you did, but 'ul' is a global option, so this
      should work just the same as :set .

      HTH --Benji Fisher
    Your message has been successfully submitted and would be delivered to recipients shortly.