On 10/20/2011 3:50 AM, Andy Wokula wrote:
Am 19.10.2011 04:21, schrieb David Fishburn:
On 1/29/2009 7:34 AM, Andy Wokula wrote:
....
omap w w<SID>copyreg
" if the following is repeated with "." (e.g. "df_.") the expression
" will not be evaluated again:
ono<expr><script> f "f".<sid>Getchar(). "<SID>copyreg"
ono<expr><script> F "F".<sid>Getchar(). "<SID>copyreg"
" (should work as well:)
" omap<expr> f "f".<sid>Getchar(). "<SID>copyreg"
map . .<SID>copyreg
nnoremap<silent> <SID>copyreg :call<sid>Record()<cr>
inoremap<silent> <SID>copyreg<C-R>=<sid>Record()<cr>
Andy,
You recommended the following code (which I have been using) some
time ago.
I find i am in a situation where I need to pass parameters to
<sid>Record().
So expression mapping code does the following:
nnoremap <silent> <SID>yrrecord :call YRRecord3()<cr>
inoremap <silent> <SID>yrrecord <C-R>=YRRecord3()<cr>
function! YRMapsExpression(sid, motion, ...)
Here is an existing map:
o y YRMapsExpression("<SNR>107_", "y")
The end of the YRMapsExpreesion function appends the call to the
let cmds .= a:sid. "yrrecord"
What I would like to do is the following, though I am not certain of
the syntax given this setup.
Basically, I want the following:
nnoremap <silent> <SID>yrrecord :call YRRecord3( myMotionParameter )<cr>
inoremap <silent> <SID>yrrecord <C-R>=YRRecord3( myMotionParameter )<cr>
function! YRMapsExpression(sid, motion, ...)
Here is an existing map with the motion at the end:
o y YRMapsExpression("<SNR>107_", "y")
The end of the YRMapsExpreesion function appends the call to the
let cmds .= a:sid. "yrrecord" "y"
So, in the end call YRRecord3("y")
Is this possible using the setup above with the expressions?
Thanks,
Dave
Hi Dave!
You want mappings with parametrized left-hand-side (?) -- there is no
such thing in Vim.
Could you say more about the purpose of the additional parameter?
So basically we have a omap (expression map) on y which call
YRMapsExpression:
o y YRMapsExpression("<SNR>107_", "y")
When I hit yy, YRMapsExpression is called, and it tacks on the call to:
nnoremap <silent> <SID>yrrecord :call YRRecord3( myMotionParameter )<cr>
let cmds .= a:sid. "yrrecord"
return cmds
So, when this executes, it also executes the call to YRRecord3().
Other expression maps are created as well:
ye
yw
yb
...
Basically, in YRRecord3(), I want to know that "ye" was called. Right
now, I have no idea what mapping triggered the call to this function.
I could simply create a script variable and in YRMapsExpression do this:
let s:yr_last_motion = 'ye'
Then in YRRecord3(), I have a reference to it.
What I was worried about in this approach is the nesting of cmds and
mappings, and the issue of what happens when I run macros.
I wasn't sure I would have a proper stack of calls when only using a
script variable.
What do you think?
Thanks,
Dave
--
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