Re: Vim 7.0f BETA

2006-04-25 Thread Bram Moolenaar

Eric Arnold wrote:

> It isn't clear how the 't' mode is different from 'm'?  I thought the
> point of feedkeys() was that all the keys were to be used as typed by
> a user?

"as if typed" is not a very clear explanation.  Obviously the keys are
not really typed, thus there are always small differences.

Remapping is one thing, whether keys are considered typed is another.
This matters for breaking undo, opening folds, etc.  It will cause
trouble, I know.  But that's what feedkeys() will do, you will have to
figure out how to use it.

-- 
[clop clop]
GUARD #1:  Halt!  Who goes there?
ARTHUR:It is I, Arthur, son of Uther Pendragon, from the castle of
   Camelot.  King of the Britons, defeator of the Saxons, sovereign of
   all England!
GUARD #1:  Pull the other one!
  The Quest for the Holy Grail (Monty Python)

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


Re: Vim 7.0f BETA

2006-04-25 Thread Eric Arnold
't' sound promising (you might want to add the below explanation or
something to the help file).

I'm trying to use the 't' key to funnel input to the  ":"  and "/"
prompt from inside a script.

I'm finding that using feedkeys() in conjunction with getchar() causes
Vim to hang in some loop:


let s:counter = 0
while 1
let s:counter += 1
echo "#" . s:counter . ":"
let inp = getchar()

if nr2char( inp ) != "" | let inp = nr2char( inp ) | endif

if inp == "\" | break | endif

call feedkeys( inp, 't' )
redraw
endwhile

In this example, it waits for the first char, and then after that
"getchar()" returns immediately with the first char you entered,
forever and ever and ...



On 4/25/06, Yakov Lerner <[EMAIL PROTECTED]> wrote:
> On 4/25/06, Eric Arnold <[EMAIL PROTECTED]> wrote:
> > It isn't clear how the 't' mode is different from 'm'?  I thought the
> > point of feedkeys() was that all the keys were to be used as typed by
> > a user?
>
> The difference between 'm' and 'n' is like difference between
> :norm and norm!. Keys coming from :norm and from feedkeys(,'m')
> are remapped, but not treated same was as coming from interactive
> user. For example, completion will not trigger.
>
> With 't', keys work same way as if coming from interactive user.
> For example completion will work. :norm and mapping
> are not capable of triggering completions. (Keys from
> map-expansions are marked as "noninteractive" keys).
>
> Yakov
>


Re: Vim 7.0f BETA

2006-04-25 Thread Yakov Lerner
On 4/25/06, Eric Arnold <[EMAIL PROTECTED]> wrote:
> It isn't clear how the 't' mode is different from 'm'?  I thought the
> point of feedkeys() was that all the keys were to be used as typed by
> a user?

The difference between 'm' and 'n' is like difference between
:norm and norm!. Keys coming from :norm and from feedkeys(,'m')
are remapped, but not treated same was as coming from interactive
user. For example, completion will not trigger.

With 't', keys work same way as if coming from interactive user.
For example completion will work. :norm and mapping
are not capable of triggering completions. (Keys from
map-expansions are marked as "noninteractive" keys).

Yakov


Re: Vim 7.0f BETA

2006-04-25 Thread Eric Arnold
It isn't clear how the 't' mode is different from 'm'?  I thought the
point of feedkeys() was that all the keys were to be used as typed by
a user?

On 4/25/06, Yakov Lerner <[EMAIL PROTECTED]> wrote:
> On 4/25/06, Robert Cussons <[EMAIL PROTECTED]> wrote:
> > Bram's last announcement mentioned:
> >
> > - Added the feedkeys() function: put keys in the typeahead queue.
> >
> > Is this something that has been just added in Vim 7.0 or is it added in
> > the sense of it had been left out of Vim 7.0 by mistake and has now been
> > added ... ?
> It was added now.
>
> > ... and more interestingly, what does it do?
>
> feedkeys( {string} [, {mode}])  Number  add key sequence to typeahead buffer
>
> feedkeys({string} [, {mode}])   *feedkeys()*
> Characters in {string} are queued for processing as if they
> come from a mapping or where typed by user.  They are added to
> the end of the typeahead buffer, thus if a mapping is still
> being executed these characters come after them.
> The function does not wait for processing of keys contained in
> {string}.
> To include special keys into {string}, use double-quotes
> and "\..." notation |expr-quote|. For example,
> feedkeys("\") simulates pressing of the Enter key. But
> feedkeys('\') pushes 5 characters.
> 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
> 't' handle keys as if typed; otherwise they are handled as
> if coming from a mapping
> Return value is always 0.
>


Re: Vim 7.0f BETA

2006-04-25 Thread Yakov Lerner
On 4/25/06, Robert Cussons <[EMAIL PROTECTED]> wrote:
> Bram's last announcement mentioned:
>
> - Added the feedkeys() function: put keys in the typeahead queue.
>
> Is this something that has been just added in Vim 7.0 or is it added in
> the sense of it had been left out of Vim 7.0 by mistake and has now been
> added ... ?
It was added now.

> ... and more interestingly, what does it do?

feedkeys( {string} [, {mode}])  Number  add key sequence to typeahead buffer

feedkeys({string} [, {mode}])   *feedkeys()*
Characters in {string} are queued for processing as if they
come from a mapping or where typed by user.  They are added to
the end of the typeahead buffer, thus if a mapping is still
being executed these characters come after them.
The function does not wait for processing of keys contained in
{string}.
To include special keys into {string}, use double-quotes
and "\..." notation |expr-quote|. For example,
feedkeys("\") simulates pressing of the Enter key. But
feedkeys('\') pushes 5 characters.
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
't' handle keys as if typed; otherwise they are handled as
if coming from a mapping
Return value is always 0.