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 understand that silencing an interactive command should work this way,
> but when there are keys to be consumed, especially fed in advance using
> feedkeys(), what is wrong in feeding to the interactive command? To me,
> the usefulness of feedkeys() goes down significantly if this is not
> supported. In fact, I don't know where you would need feedkeys() as
> using a dynamic mapping can already achieve this.

I don't know what you are talking about.  The "4\<CR>" in your example
is executed, the cursor moves four lines down.

Making interactive commands with ":silent" sometimes accept keys and
sometimes not makes them unpredictable.  Consider the hit-enter prompt,
for example.

> All interactive commands in unix work with redirected stdio (well,
> except those that directly open the console, which are very rare), and
> why shouldn't this be the case with vim commands? We have output
> redirection for interactive commands, why can't they have a way to take
> input by other means?

You are over-generalizing.  Does firefox redirect stdio?  Does "reboot"?
This only applies to commands that were made to be used in a pipe.

-- 
ARTHUR: Charge!
   [They all charge with swords drawn towards the RABBIT.  A tremendous twenty
   second fight with Peckinpahish shots and borrowing heavily also on the
   Kung Fu and karate-type films ensues, in which some four KNIGHTS are
   comprehensively killed.]
ARTHUR: Run away!  Run away!
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

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