Hi Bram!

On Do, 04 Nov 2010, Bram Moolenaar wrote:

> Right, it's already inconsistent.  A number for "u" means the number of
> times to undo, for ":undo" it means a change number to jump to.  Hmm, in
> that context ":undo 123f" does make sense.  But the relation with
> ":earlier 1f" and :later 1f" is a bit messy.  We could introduce a new
> command for that.  Could be ":undojump" and accept the same arguments
> are :earlier and :later, but as an absolute number.  Could also make
> this work for time (conversion from string to seconds might not be so
> easy though).

I wouldn't do this. I like it the way it is. 'u' jumps within the 
current undo branch and :undo jumps to any other (absolute) position. 
One could make it accept an absolute date/time stamp. But IMHO there is 
no need for :undojump, IMHO. 

> This is a hint for a much simpler implementation: subtract the current
> save number from the desired one and executed an :earlier or :laster
> command.  Wouldn't that work?

Like the attached patch does? Or do you mean to implement it in 
VimScript, like this:

func! s:Undo(...)
     let nr=undotree().save_cur
     if empty(a:000) 
        exe "earlier " . nr . "f"
     elseif (a:1 - nr < 0)
        exe "earlier " . (nr - a:1) . "f"
     else
        exe "later " . (a:1 - nr) . "f"
    endif
endfunc
com! -nargs=? UndoSave call s:Undo(<q-args>)

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
diff --git a/runtime/doc/undo.txt b/runtime/doc/undo.txt
--- a/runtime/doc/undo.txt
+++ b/runtime/doc/undo.txt
@@ -27,6 +27,9 @@
 :u[ndo] {N}		Jump to after change number {N}.  See |undo-branches|
 			for the meaning of {N}.  {not in Vi}
 
+:u[ndo] {N}f		Jump to after save number {N}.  See |undo-branches|
+			for the meaning of {N}.  {not in Vi}
+
 							*CTRL-R*
 CTRL-R			Redo [count] changes which were undone.  {Vi: redraw
 			screen}
diff --git a/src/ex_cmds.h b/src/ex_cmds.h
--- a/src/ex_cmds.h
+++ b/src/ex_cmds.h
@@ -996,7 +996,7 @@
 EX(CMD_tunmenu,		"tunmenu",	ex_menu,
 			EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN),
 EX(CMD_undo,		"undo",		ex_undo,
-			RANGE|NOTADR|COUNT|ZEROR|TRLBAR|CMDWIN),
+			RANGE|NOTADR|COUNT|ZEROR|TRLBAR|CMDWIN|WORD1),
 EX(CMD_undojoin,	"undojoin",	ex_undojoin,
 			TRLBAR|CMDWIN),
 EX(CMD_undolist,	"undolist",	ex_undolist,
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -8493,9 +8493,34 @@
  */
     static void
 ex_undo(eap)
-    exarg_T	*eap UNUSED;
-{
-    if (eap->addr_count == 1)	    /* :undo 123 */
+    exarg_T	*eap;
+{
+    long	count = 0;
+    int         file  = FALSE;
+    char_u	*p = eap->arg;
+
+    if (*p == NUL)
+	count = 1;
+    else if (*p == 'f')
+    {
+	++p;
+	file = TRUE;
+    }
+
+    if (*p != NUL)
+	EMSG2(_(e_invarg2), eap->arg);
+    else if (file)
+    {
+        if (eap->line2 < 0)
+	  count = 1;
+	else if (eap->line2 > curbuf->b_u_save_nr_last)
+	  count = curbuf->b_u_save_nr_last;
+	else
+	  count = eap->line2;
+        count = count - curbuf->b_u_save_nr_cur;
+	undo_time(count, FALSE, file, FALSE);
+    }
+    else if (eap->addr_count == 1)	    /* :undo 123 */
 	undo_time(eap->line2, FALSE, FALSE, TRUE);
     else
 	u_undo(1);

Raspunde prin e-mail lui