--- eval.c.000	2006-04-21 14:32:30.000000000 +0300
+++ eval.c	2006-04-21 19:39:36.000000000 +0300
@@ -586,6 +586,7 @@
 static void f_prevnonblank __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_printf __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_pumvisible __ARGS((typval_T *argvars, typval_T *rettv));
+static void f_pushkeys __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_range __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_readfile __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_reltime __ARGS((typval_T *argvars, typval_T *rettv));
@@ -7093,6 +7094,7 @@
     {"prevnonblank",	1, 1, f_prevnonblank},
     {"printf",		2, 19, f_printf},
     {"pumvisible",	0, 0, f_pumvisible},
+    {"pushkeys",        1, 2, f_pushkeys},
     {"range",		1, 3, f_range},
     {"readfile",	1, 3, f_readfile},
     {"reltime",		0, 2, f_reltime},
@@ -12576,6 +12578,38 @@
 }
 
 /*
+ * "pushkeys()" function
+ */
+/*ARGSUSED*/
+    static void
+f_pushkeys(argvars, rettv)
+    typval_T    *argvars;
+    typval_T    *rettv;
+{
+    int		remap = TRUE;
+    char_u	*keys, *flags;
+    char_u	nbuf[NUMBUFLEN];
+
+    rettv->vval.v_number = 0;
+    keys = get_tv_string(&argvars[0]);
+    if( *keys != NUL ) {
+	flags = get_tv_string_buf(&argvars[1], nbuf);
+
+	for (; *flags != NUL; ++flags)
+	{
+	    switch (*flags)
+	    {
+		case 'n': remap = FALSE; break;
+		case 'm': remap = TRUE; break;
+	    }
+	}
+
+	ins_typebuf(keys, (remap ? REMAP_YES : REMAP_NONE), 
+					    typebuf.tb_len, TRUE, FALSE); 
+    }
+}
+
+/*
  * "range()" function
  */
     static void
--- getchar.c.000	2006-04-21 19:05:24.000000000 +0300
+++ getchar.c	2006-04-21 19:58:02.000000000 +0300
@@ -2914,14 +2914,18 @@
 /*
  * Return TRUE when bytes are in the input buffer or in the typeahead buffer.
  * Normally the input buffer would be sufficient, but the server_to_input_buf()
- * may insert characters in the typeahead buffer while we are waiting for
- * input to arrive.
+ * or pushkeys() may insert characters in the typeahead buffer while we are
+ * waiting for input to arrive.
  */
     int
 input_available()
 {
-    return (!vim_is_input_buf_empty()
+    return (!vim_is_input_buf_empty() || typebuf.tb_len
 # ifdef FEAT_CLIENTSERVER
+			    /* Is '|| received_from_client' needed here, now */
+			    /*   that typebuf.tb_len is checked here in the */
+			    /*   same condition when pushkeys() can now also */
+			    /*   add to typebuf ? lerner */
 	    || received_from_client
 # endif
 	    );
--- ../runtime/doc/eval.txt.000	2006-04-21 15:05:30.000000000 +0300
+++ ../runtime/doc/eval.txt	2006-04-21 19:50:52.000000000 +0300
@@ -1657,6 +1657,7 @@
 prevnonblank( {lnum})		Number	line nr of non-blank line <= {lnum}
 printf( {fmt}, {expr1}...)	String  format text
 pumvisible()			Number  whether popup menu is visible
+pushkeys({string} [, {mode}])	Number  add key sequence to typeahead buffer
 range( {expr} [, {max} [, {stride}]])
 				List	items from {expr} to {max}
 readfile({fname} [, {binary} [, {max}]])
@@ -3778,6 +3779,19 @@
 		This can be used to avoid some things that would remove the
 		popup menu.
 
+pushkeys({string} [, {mode}])				*pushkeys()*
+		Characters in {string} are queued for processing as if they
+		were typed by user. The function returns immediately,
+		does not wait until keys contained in {string} are
+		executed. To include special keys into {string}, use
+		double-quotes and backslash notation |expr-quote|. Notation
+		"\<XXX>" is useful for named special keys. 
+		If {mode} is absent, keys are remapped.
+		{mode} is a String, which can contain these character flags:
+		'm'	remap keys. This is default.
+		'n'	do not remap keys
+		Return value is always 0.
+
 							*E726* *E727*
 range({expr} [, {max} [, {stride}]])				*range()*
 		Returns a |List| with Numbers:
