On Tue, 11 Apr 2006 09:39:05 -0400
Benji Fisher <[EMAIL PROTECTED]> wrote:
> On Tue, Apr 11, 2006 at 01:06:11PM +0200, Christoph Nodes wrote:
> > > >
> > > > Is there a way to avoid that the changes a specific command makes
> > > > are added to the undo history. I am missing something like
> > > > histdel("undo", -1). "Set undolevels = -1" is no choice since I
> > > > don't want to lose the changes I made before.
> >
> > The reason for my question is our way of handling the
> > "Gtk-Utf-8-String-problem": Gtk-2.0 functions take UTF-8-encoded
> > strings as arguments. For constant strings coded into the source code
> > this can be a problem if you use characters not included in the ascii
> > character set and you don't want to have UTF-8-encoded source files.
> > Our way is to let vim do the encoding and call a vim function on every
> > BufReadPost and BufWritePre event that uses iconv() to convert these
> > constant
> > strings. These changes however, are changes that we don't want to undo/redo.
> >
> > Christoph
>
> If you are using vim 7.0 (still in beta testing), then you may be
> able to accomplish what you want with :undojoin .
>
> :help :undojoin
>
> HTH --Benji Fisher
Thanks for your hint but this is still not quite what I want. It looks like as
it
is not possible to erase an undo history entry.
I was wondering if there is somebody here who could have a look at the patch I
wrote
for the vim-70d version that introduces the :undodelete command. It seems to
work but
it is sparely tested. Maybe I am overseeing something important ...
Thanks in advance
> cat vim70d-undelete-patch
diff -u -r vim70d/src/proto/undo.pro vim70d-undodelete/src/proto/undo.pro
--- vim70d/src/proto/undo.pro 2006-04-10 14:22:47.000000000 +0200
+++ vim70d-undodelete/src/proto/undo.pro 2006-04-12 13:05:00.000000000
+0200
@@ -9,6 +9,7 @@
extern void undo_time __ARGS((long step, int sec, int absolute));
extern void u_sync __ARGS((int force));
extern void ex_undolist __ARGS((exarg_T *eap));
+extern void ex_undodelete __ARGS((exarg_T *eap));
extern void ex_undojoin __ARGS((exarg_T *eap));
extern void u_unchanged __ARGS((buf_T *buf));
extern void u_clearall __ARGS((buf_T *buf));
diff -u -r vim70d/src/undo.c vim70d-undodelete/src/undo.c
--- vim70d/src/undo.c 2006-04-10 12:01:29.000000000 +0200
+++ vim70d-undodelete/src/undo.c 2006-04-12 19:21:12.000000000 +0200
@@ -1398,6 +1398,30 @@
}
/*
+ * ":undodelete": delete the last undo block
+ */
+/*ARGSUSED*/
+ void
+ex_undodelete(eap)
+ exarg_T *eap;
+{
+ if (curbuf->b_u_newhead == NULL)
+ return;
+ if (p_ul < 0)
+ return; /* no entries, nothing to do */
+ else
+ {
+ u_header_T *uhfree = curbuf->b_u_newhead;
+ u_header_T *curhead = curbuf->b_u_curhead;
+
+ if (!curbuf->b_u_synced)
+ u_sync(TRUE);
+ if (uhfree->uh_alt_next == NULL)
+ u_freeheader(curbuf, uhfree, &curhead);
+ }
+}
+
+/*
* ":undojoin": continue adding to the last entry list
*/
/*ARGSUSED*/