This patch implements persistent undo. It is against SVN revision  
1365. I'd like to submit it to the list to see what people think.

More specifically, here are the changes:
1. Added commands :wundo and :rundo that write and read undo files  
respectively. An undo file is a binary file that contains an undo  
tree. One of these will exist for every file whose undo tree is saved.
2. Added 'undofile'/'udf' option that toggles automatic undo file  
writing and reading. If a file's checksum changed since the last time  
it had an undo file written for it, Vim will silently (or loudly, with  
verbose > 0) ignore the undo file when editing the file.
3. Added 'undodir'/'udir' option that defines a list of directories in  
which to save the undo files. I copied the per-OS default values for  
this option based on the swapfile 'dir' option.
4. Added simple crc32 checksum based on the crc32 crypto in misc2.c  
and a function to checksum a buffer.
5. Made the get2c, get3c, and get4c functions in spell.c not static  
since they were useful to me. Perhaps these belong in one of the  
misc.c files now?
6. Added calls to u_wundo and u_rundo where files get written/read if  
undofile is set. It seems like I had to put these calls in too many  
places, perhaps there is a better place for them?

To test it, you'll need to:
1. set the 'undofile' or 'udf' option in your .vimrc
2. mkdir .vim/undo, or set undodir to something else and mkdir it
3. change a file, :wq, reload, and your undo tree should be loaded


Things to note:
1. I have only tested this patch on Linux (32- and 64-bit) and OS X  
machines.
2. If the checksum of a file changes in between edits, the patch will  
not load the undo file. A message will get displayed about this if  
your verbose is greater than 0.
3. The undo files are saved in a binary format. I have put some simple  
safety checks in the unserialization function, but if you edit the  
undo file, there is a high likelihood that Vim will choke.
4. I didn't give error numbers to the new error messages I defined. I  
suspect that this is important, but I wasn't sure how the numbering  
scheme works.


Known bug:
If you edit a file inside of a zip archive and save changes, Vim will  
segfault when you re-edit it later and it tries to load the undofile.  
I suspect this is because Vim seems to have two different types of  
canonical name for files within zip archives, and the undo file  
mechanism somehow mismatches these representations. I am unfamiliar  
with the mechanics of Vim's zip file support, so I thought I would ask  
the list for advice on how to fix this issue.


Comments and suggestions would be greatly appreciated.

- Jordan Lewis


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Attachment: persistent_undo.diff
Description: Binary data



Raspunde prin e-mail lui