On Thu, 20 Oct 2011, David Fishburn wrote:
[...]
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.
I don't quite grok the full context, but why not make it explicitly a
stack? Instead of:
let s:yr_last_motion = 'ye'
do:
call add(s:motion_context, 'ye')
and (when the info is consumed):
call remove(s:motion_context, -1)
--
Best,
Ben
--
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