[vim73] easy way to purge 'persistence undo'?

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

[vim73] easy way to purge 'persistence undo'?

SungHyun Nam-2
Hello,

With vim-7.2, I did ':e' to purge undo history to start new
'edit session'(?).

With vim-7.3 (+ 'undofile'):
I guess I could remove a undofile and run ':e' to do this.  Maybe
I can make a mapping with some vim script, but...

Is there any easy way to purge 'persistence undo' history?

Thanks,
namsh

--
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
Reply | Threaded
Open this post in threaded view
|

Re: [vim73] easy way to purge 'persistence undo'?

Christian Brabandt
Hi SungHyun!

On Do, 03 Jun 2010, SungHyun Nam wrote:

> With vim-7.3 (+ 'undofile'):
> I guess I could remove a undofile and run ':e' to do this.  Maybe
> I can make a mapping with some vim script, but...
>
> Is there any easy way to purge 'persistence undo' history?

Try setting ul=-1

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
Reply | Threaded
Open this post in threaded view
|

Re: [vim73] easy way to purge 'persistence undo'?

Dominique Pellé
Christian Brabandt wrote:

> Hi SungHyun!
>
> On Do, 03 Jun 2010, SungHyun Nam wrote:
>
>> With vim-7.3 (+ 'undofile'):
>> I guess I could remove a undofile and run ':e' to do this.  Maybe
>> I can make a mapping with some vim script, but...
>>
>> Is there any easy way to purge 'persistence undo' history?
>
> Try setting ul=-1

I tried this:

:set undolevels?
  undolevels=4000

:set undolevels=-1
:set undolevels=4000

And the undo history was *not* purged.  Undo history is
only purged if I edit something in between the 2
":set undolevels=...":

:set undolevels=-1
.. edit something...
:set undolevels=4000
(undo history is now purged)

I'm not sure how useful it is to be able to purge undo history anyway.
I don't think I would need to do that.  What I would find more
useful, when performing multiple undos with persistent-undo, is to
display a message such as:

"undo reached state where file was last read/written"

... so that user is warned when doing multiple undos that it can
go back in time earlier than when file was last read/written if he
continues to undo.

I see an item added recently on the todo list which would also be useful:

- undofile: keep markers where the file was written/read, so that it's easy to
  go back to a saved version of the file  ":earlier 1file"?

Cheers
-- Dominique

--
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
Reply | Threaded
Open this post in threaded view
|

Re: [vim73] easy way to purge 'persistence undo'?

SungHyun Nam-2
Dominique Pellé wrote:

> Christian Brabandt wrote:
>
>> Hi SungHyun!
>>
>> On Do, 03 Jun 2010, SungHyun Nam wrote:
>>
>>> With vim-7.3 (+ 'undofile'):
>>> I guess I could remove a undofile and run ':e' to do this.  Maybe
>>> I can make a mapping with some vim script, but...
>>>
>>> Is there any easy way to purge 'persistence undo' history?
>>
>> Try setting ul=-1
>
> I tried this:
>
> :set undolevels?
>    undolevels=4000
>
> :set undolevels=-1
> :set undolevels=4000
>
> And the undo history was *not* purged.  Undo history is
> only purged if I edit something in between the 2
> ":set undolevels=...":
>
> :set undolevels=-1
> .. edit something...
> :set undolevels=4000
> (undo history is now purged)
>
> I'm not sure how useful it is to be able to purge undo history anyway.
> I don't think I would need to do that.  What I would find more
> useful, when performing multiple undos with persistent-undo, is to
> display a message such as:
>
> "undo reached state where file was last read/written"
>
> ... so that user is warned when doing multiple undos that it can
> go back in time earlier than when file was last read/written if he
> continues to undo.

Well, it might be just my editing style. When I edit a C
source and compile (and test), I purged the undo history (and
maybe checkin to GIT repo).  And edit again, if something is
wrong, I just pressed 'u' until I return to purged state.  So to
me, even the warning message is not perfect, because I want to go
back fast (don't want to check message while I press 'u').

And I made a function, it works for me.

     func! util#purgeUndoHistory()
       let file = undofile(expand('%:p'))
       if filereadable(file)
         let oldundofile = &l:undofile
         setl noundofile
         silent! exec "!rm -f ".file
         e
         let &l:undofile = oldundofile
       endif
     endfunc

> I see an item added recently on the todo list which would also be useful:
>
> - undofile: keep markers where the file was written/read, so that it's easy to
>    go back to a saved version of the file  ":earlier 1file"?
>
> Cheers
> -- Dominique
>

Thanks,
namsh

--
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
Reply | Threaded
Open this post in threaded view
|

Re: [vim73] easy way to purge 'persistence undo'?

SungHyun Nam-2
SungHyun Nam wrote:

> Dominique Pellé wrote:
>> Christian Brabandt wrote:
>>> On Do, 03 Jun 2010, SungHyun Nam wrote:
>>>
>>>> With vim-7.3 (+ 'undofile'):
>>>> I guess I could remove a undofile and run ':e' to do this.  Maybe
>>>> I can make a mapping with some vim script, but...
>>>>
>>>> Is there any easy way to purge 'persistence undo' history?
>
> And I made a function, it works for me.
>
>      func! util#purgeUndoHistory()
>        let file = undofile(expand('%:p'))
>        if filereadable(file)
>          let oldundofile = &l:undofile
>          setl noundofile
>          silent! exec "!rm -f ".file
>          e
>          let &l:undofile = oldundofile
>        endif
>      endfunc

No, it did NOT work. :-(
Edit and save a 'file.c', and...
     $ vim file.c
     :call util#purgeUndoHistory()
And if I type 'u', vim displays:
     Already at oldest change

But, when I exit VIM and open the file.c again, 'u' works again.

And I found the undofile was not removed.  The exec line should be
changed to:
           silent! exec "!rm -f ".escape(file, '%')

Thanks,
namsh

--
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
Reply | Threaded
Open this post in threaded view
|

Re: easy way to purge 'persistence undo'?

Benjamin Fritz
In reply to this post by Dominique Pellé


On Jun 3, 1:48 pm, Dominique Pellé <[hidden email]> wrote:

>
> I'm not sure how useful it is to be able to purge undo history anyway.
> I don't think I would need to do that.  What I would find more
> useful, when performing multiple undos with persistent-undo, is to
> display a message such as:
>
> "undo reached state where file was last read/written"
>
> ... so that user is warned when doing multiple undos that it can
> go back in time earlier than when file was last read/written if he
> continues to undo.
>
> I see an item added recently on the todo list which would also be useful:
>
> - undofile: keep markers where the file was written/read, so that it's easy to
>   go back to a saved version of the file  ":earlier 1file"?
>

I would also need such a feature. I will often either hold down 'u' or
use :earlier 24h or whatever, to return to the state of the buffer
when I started editing.

I do think that purging the undo history could be useful in some
situations. If it is complicated to do (using a function as shown in
this thread), we should probably put an example of how to do it in
the :help or add a command to do it.

--
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
Reply | Threaded
Open this post in threaded view
|

Re: [vim73] easy way to purge 'persistence undo'?

Ingo Karkat
In reply to this post by Dominique Pellé
On 03-Jun-2010 20:48, Dominique Pellé wrote:
> I see an item added recently on the todo list which would also be useful:
>
> - undofile: keep markers where the file was written/read, so that it's easy to
>    go back to a saved version of the file  ":earlier 1file"?

Though some may object that this makes Vim further encroach on the territory of
a proper Revision Control System, I would find such a movement along saved file
versions very useful. So far, I've been using my writebackup.vim plugin [1] for
such short-term temporary versions. +1 from me for :earlier 1file

I like the idea of a command to purge the undo information, if only for
security/privacy reasons. (Imagine you've accidentally pasted your credit card
info into a Vim buffer; you don't want to have that persisted to disk.)

-- regards, ingo

[1] http://www.vim.org/scripts/script.php?script_id=1828

--
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
Reply | Threaded
Open this post in threaded view
|

Re: easy way to purge 'persistence undo'?

Benjamin Fritz


On Jun 4, 2:07 pm, Ingo Karkat <[hidden email]> wrote:

> On 03-Jun-2010 20:48, Dominique Pell wrote:
>
> > I see an item added recently on the todo list which would also be useful:
>
> > - undofile: keep markers where the file was written/read, so that it's easy to
> >    go back to a saved version of the file  ":earlier 1file"?
>
> Though some may object that this makes Vim further encroach on the territory of
> a proper Revision Control System, I would find such a movement along saved file
> versions very useful. So far, I've been using my writebackup.vim plugin [1] for
> such short-term temporary versions. +1 from me for :earlier 1file
>

I only recently started using undo branches, thanks to my discovery of
the histwin plugin:

http://www.vim.org/scripts/script.php?script_id=2932

With :earlier 1file being available, which would probably involve
appropriate (parseable) markers, I imagine this plugin could readily
be expanded to show these file tags, giving you even more information
to help determine what state the times on the branches actually
correspond to.

--
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
Reply | Threaded
Open this post in threaded view
|

Re: easy way to purge 'persistence undo'?

Dominique Pellé
Ben Fritz wrote:

> I only recently started using undo branches, thanks to my discovery of
> the histwin plugin:
>
> http://www.vim.org/scripts/script.php?script_id=2932
>
> With :earlier 1file being available, which would probably involve
> appropriate (parseable) markers, I imagine this plugin could readily
> be expanded to show these file tags, giving you even more information
> to help determine what state the times on the branches actually
> correspond to.

I find the undo branches very nice but also hard to use in practice.
I tend to get lost where I am in the tree when using :undo or :earlier
commands.  Currently, the ":undolist" command only shows something
like this:

  :undolist
  number changes time
  1          15  08:53:07
  5          18  08:53:20
  7          14  08:53:29

Would it be possible to draw the structure of the undo tree?
What about the following mock up (use a fixed size font to properly
view the ASCII art):

  :undolist
  number changes time
  1          15  08:53:07  <--3--o-------------12-->
  5          18  08:53:20        \--1--S-------14-->
  7          14  08:53:29              \--8--*--2-->


Where:
  <  ... is a root node in the tree. There is generally only 1 root node
         as in above example. However, because of limited undo levels,
         there can also be more than root node.
  o  ... is a node in the undo tree from which multiple sub-branches start.
  \  ... is the start of a sub-branch.
  >  ... is a leaf node in the undo tree.
  S  ... is the tag of node where file was last (S)aved.
  *  ... is the current position in the undo tree. It is often located on
         a leaf. However, when using :undo or :earlier commands, it may not
         be located on a leaf. In above example, user has undone 2 changes
         from the leaf in last branch so * is not located on a leaf.

The numbers represent the number of intermediate changes between
nodes o \ > S * in undo tree.

I realize that drawing the undo tree may be tricky when the undo tree
becomes large: it may then not fit on the width of the screen.  In that
case, it could be truncated.

It would make the undo tree structure more intuitive.
What do you think?

-- Dominique

--
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
Reply | Threaded
Open this post in threaded view
|

Re: [vim73] easy way to purge 'persistence undo'?

Christian Brabandt
In reply to this post by Ingo Karkat
Hi Ingo!

On Fr, 04 Jun 2010, Ingo Karkat wrote:

> I like the idea of a command to purge the undo information, if only for  
> security/privacy reasons. (Imagine you've accidentally pasted your credit
> card info into a Vim buffer; you don't want to have that persisted to
> disk.)

How about something like this:

if has('persistent_undo')
    com! DeleteUndoFile :call delete(undofile(expand("%")))|echohl WarningMsg|echo "Undofile " . undofile(expand("%")) . " deleted!" | echohl Normal
endif

BTW: if I set ul=-1 and write the file, I also loose my undo history.
But as this is a global option, it will also affect all open buffers.

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