Hari Kirshna Dara wrote:

> I am trying to use feedkeys() to give input to a Vim command that is
> expecting input from the user, and it works if the command is not
> executed using :silent prefix. Here is an example (executed on JDK 1.4.2
> source):
> 
> :ta Integer
> tag 1 of 11 or more
> :call feedkeys("4\<CR>") | ts
> <takes me to the 4th tag>
> 
> If I prefix the :ts command with :silent, this doesn't work, and the fed
> keys are handled by Vim as normal mode commands.
> 
> :call feedkeys("4\<CR>") | silent ts

If you try ":silent ts" manually you will see that this doesn't work
either.  This has nothing to do with feedkeys().  If you silence an
interactive command you can predict it won't work.  This is mostly to
prevent Vim from an apparent hang when someone uses ":silent" for an
interactive command (often indirectly).

> I was doing this (feeding keys) in Vim 6.3 using a dynamic mapping,
> which suffered from the same problem, so had to use the command without
> silent, and that is a big usability issue, so was really hoping that
> feedkeys() will solve this problem, but unfortuately it doesn't.
> 
> Also, I just observed that while experimenting with feedkeys(), Vim went
> into a loop. It responds to ^C with a beep, but ignores all my other
> keys. It essentially stopped responding to user input (keyboard and
> mouse), but quit gracefully when I hit the window close button. Here is
> how to reproduce it (again using JDK 1.4.2 source, but should work on
> any tags):
> 
> :ta Integer
> :ta Integer
> :call feedkeys("4\<CR>") | silent ts
> ^T
> :call feedkeys("4\<CR>") | silent ts
> E426: tag not found: Integer
> <non-responding Vim>
> 
> The "^T" is to return back to the previous tag in the stack.

This looks like a bug...  Well, here you can see how adding something
without know exactly what happens messes up things.  feedkeys() sets the
typebuf_was_filled flag and that causes the loop.  I'll change that.
Hopefully this will work:

--- eval.c      27 Apr 2006 00:02:04 -0000      1.170
+++ eval.c      27 Apr 2006 09:58:48 -0000
@@ -9029,7 +9029,8 @@
            ins_typebuf(keys_esc, (remap ? REMAP_YES : REMAP_NONE),
                                               typebuf.tb_len, !typed, FALSE);
            vim_free(keys_esc);
-           typebuf_was_filled = TRUE;
+           if (vgetc_busy)
+               typebuf_was_filled = TRUE;
        }
     }
 }

-- 
Did you ever stop to think...  and forget to start again?
                                  -- Steven Wright

 /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

Reply via email to