Dear vim_dev,

Recently I tried to make a user function for jumping through the jump
list (by files), but it happens that there is no good interface for
that.  For example CTRL-I could possibly be only with :normal! <c-i> but
this does not work (even in vim -U NONE in the terminal, I have not
tested this in the GUI though) and also using CTRL-V will not work since
CTRL-V_CTRL-I produces a tab (this works with CTRL-O thought).
I present here a very simple patch which introduce a vim function
jump({count}).  :call jump(-5) will jump back in the jump list by
5 positions and :call jump(5) will jump forward five positions.

Any comments are welcome,
Marcin Szamotulski

-- 
-- 
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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.
diff -r 477b4f701156 runtime/doc/eval.txt
--- a/runtime/doc/eval.txt	Sun Aug 25 17:46:08 2013 +0200
+++ b/runtime/doc/eval.txt	Thu Aug 29 19:03:36 2013 +0100
@@ -1840,6 +1840,7 @@
 islocked( {expr})		Number	TRUE if {expr} is locked
 items( {dict})			List	key-value pairs in {dict}
 join( {list} [, {sep}])		String	join {list} items into one String
+jump( {count}, [, {flags}])	0	jump {count} times in the |jumplist|
 keys( {dict})			List	keys in {dict}
 len( {expr})			Number	the length of {expr}
 libcall( {lib}, {func}, {arg})	String	call {func} in library {lib} with {arg}
@@ -3880,6 +3881,11 @@
 		converted into a string like with |string()|.
 		The opposite function is |split()|.
 
+jump({count})				*jump()*
+		Jump {count} times in the |jumplist|, like {count}|CTRL-I| if
+		{count} is positive and {count}|CTRL-O| if {count} is
+		negative.
+
 keys({dict})						*keys()*
 		Return a |List| with all the keys of {dict}.  The |List| is in
 		arbitrary order.
diff -r 477b4f701156 runtime/doc/usr_41.txt
--- a/runtime/doc/usr_41.txt	Sun Aug 25 17:46:08 2013 +0200
+++ b/runtime/doc/usr_41.txt	Thu Aug 29 19:03:36 2013 +0100
@@ -692,6 +692,7 @@
 
 Cursor and mark position:		*cursor-functions* *mark-functions*
 	col()			column number of the cursor or a mark
+	jump()			jump in the |jumplist|
 	virtcol()		screen column of the cursor or a mark
 	line()			line number of the cursor or mark
 	wincol()		window column number of the cursor
diff -r 477b4f701156 src/eval.c
--- a/src/eval.c	Sun Aug 25 17:46:08 2013 +0200
+++ b/src/eval.c	Thu Aug 29 19:03:36 2013 +0100
@@ -589,6 +589,7 @@
 static void f_islocked __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_items __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_join __ARGS((typval_T *argvars, typval_T *rettv));
+static void f_jump __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_keys __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_last_buffer_nr __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_len __ARGS((typval_T *argvars, typval_T *rettv));
@@ -7978,6 +7979,7 @@
     {"islocked",	1, 1, f_islocked},
     {"items",		1, 1, f_items},
     {"join",		1, 2, f_join},
+    {"jump",		1, 1, f_jump},
     {"keys",		1, 1, f_keys},
     {"last_buffer_nr",	0, 0, f_last_buffer_nr},/* obsolete */
     {"len",		1, 1, f_len},
@@ -13476,6 +13478,30 @@
 }
 
 /*
+ * "jump()" function
+ */
+    static void
+f_jump(argvars, rettv)
+    typval_T	*argvars;
+    typval_T	*rettv;
+{
+    pos_T	*pos;
+
+    pos = movemark(argvars[0].vval.v_number);
+    if (pos == (pos_T *)-1)		/* jump to other file */
+    {
+	curwin->w_set_curswant = TRUE;
+	check_cursor();
+    }
+    else if (pos != NULL)		/* can jump */
+    {
+	curwin->w_cursor = *pos;
+	check_cursor();
+    }
+    rettv->vval.v_string = NULL;
+}
+
+/*
  * "keys()" function
  */
     static void

Raspunde prin e-mail lui