Jordan Lewis wrote:

> Hi,
>
> I've added some documentation to the patch I wrote for persistent
> undo. It's been a while since I've posted about this, so I'll recap
> the features:
>
> 1. New option 'undofile' causes Vim to automatically write out the
> undo history for the current session to a file located in the directory
> (ies) provided by the new 'undodir' option, and to automatically read
> back this undo history when the same file is opened again.
> 2. New commands :wundo and :rundo allow you to manually write and read
> undo files, respectively.
>
> The attached diff was created against SVN version 1658. Once you patch
> your source, you'll want to add 'set undofile' to your vimrc to enable
> the functionality. Then make some edits to a file, quit Vim, and open
> the file again - you will still be able to undo your edits.
>
> I've been using this patch in my Vim for close to a year now, and its
> a real productivity booster. Working on other machines without undo
> persistence has become fairly difficult for me, as I'm so used to
> being able to revert changes I've made to (for example) a LaTeX file
> after exiting Vim, creating a PDF, and noticing a mistake.
>
> Please try this patch! I think you all and the rest of the Vim
> community will really like this functionality.
>
>
> Thanks,
> Jordan Lewis

Hi Jordan

Thanks for your work!

The persistent undo feature would be very nice in my opinion.
And I see that persistent undo is quite high on the feature voting
page:

  http://www.vim.org/sponsor/vote_results.php

Some remarks about your patch:

- code compiles fine with huge version of Vim but fails to
  compile with tiny version of Vim:

  $ ./configure --with-features=tiny
  $ make
  ...
  objects/undo.o: In function `unserialize_pos':
  /tmp/vim7/src/undo.c:667: undefined reference to `get4c'
  /tmp/vim7/src/undo.c:668: undefined reference to `get4c'
  etc, etc...

- It would be best to have the persistent undo code
  within something like #ifdef FEAT_PERSISTENT_UNDO

- compilation warning:
  undo.c:1073: warning: unused variable ‘cur_seq’

- typo in undo.c:946:  strutures -> structures

- Memory leak: variable munged_name allocated at undo.c:703
  is never freed:

  702     name_len = STRLEN(ffname);
  703     munged_name = alloc(name_len + 1);
  704     mch_memmove(munged_name, ffname, name_len + 1);

- Using the same coding convention of Vim may increase your chance
  of having the patch merged in the main tree.  For example:

  if (...) {
      ...
  }

  ... should be...

  if (...)
  {
      ...
  }

- serialize_uep(...) has FILE *fp as first argument whereas
  functions serialize_pos(...) & serialize_visualinfo(...) have
  FILE *fp as last argument.  Consistent would be better.

- According to Valgrind memory checker, line undo.c:1033
  writes an uninitialized value uep->ue_lcount in
  serialize_uep(...):

     put_bytes(fp, (long_u) uep->ue_lcount, 4);

I will check further when I have time, maybe next weekend.

Cheers
-- Dominique

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

Raspunde prin e-mail lui