On 2011-02-04 ZyX <[email protected]> wrote:

> > I tried something like:
> > 
> > vim.eval"<Plug>IMAP_JumpBack"
> > 
> > But it's not working. How to call this from within lua?

> vim.eval will evaluate expression. <Plug>IMAP_JumpBack is not an
> expression. Expr definition can be found in :h expr.

Okay, thanks.

> If it was python, I
> would have used vim.command('execute "normal \\<Plug>IMAP_JumpBack"').

Bingo! That's the solution. Works in lua, too.

> > What elst can I rely on? Only the <C-R> mapping?
> You should rely on documented API. You should not rely on <C-r> mapping
> because you are going to remap it, but IMAP_JumpBack is documented.

That's what I use.

> > I want to remap <C-R> with
> > my own function and at the end of my own function I want to call the
> > function of the former mapping.
> I used to either create a temporary mapping:
> 
> [...]

Sorry, but that's too much unknown code for me. I'm not an expert in vim
programming.

> This is to be used inside an expression mappings when you cannot know what
> is the {rhs} and where it is defined. You probably don't nee such monster
> here. You may also do the following:
> 
>     imap <C-r> <Plug>MappingToYourFunction<Plug>IMAP_JumpBack

Looks much better. I'll try.

> this should also work:
> 
>     function ExecuteJumpBack()
>         return "\<Plug>IMAP_JumpBack"
>     endfunction
>     imap <expr> {lhs} ExecuteJumpBack()
> The following can also work, but I did not test it:
>     imap        {lhs} <C-r>=ExecuteJumpBack()<CR>
> 
> Other possibilities:
> 
>     function ExecuteJumpBack()
>         execute "normal i\<Plug>IMAP_JumpBack"
>     endfunction
>     function ExecuteJumpBack()
>         " Assuming that after function execution it will be still in insert
> mode call feedkeys("\<Plug>IMAP_JumpBack")
>     endfunction

Thanks for the suggestions. I'll play with them.


Regards
Marco


-- 
You received this message from the "vim_use" 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

Reply via email to