On Jan 30, 9:27 am, dr-dr xp <
drdr...@gmail.com> wrote:
>
> To your last requirement, I think this is what you want:
> XPT foo " tips
> this is `foo^
>
> XPT helloxpt " tips about what this snippet does
> XSET x|post=Build( '`:' . ( ( { "a" : "foo", "b" : "bar" } )[ V() ] ) . ':^'
> )
> -`x^=
>
> function "V()" retrieves the "value" of current place holder.
Thank you! That's great! This is just what I was looking for.
Now I can have multiple popups, like so:
XPT foo " tips
`_foo_popup^
XSET _foo_popup=Choose([ '123', '456' ])
XPT bar " tips
`_bar_popup^
XSET _bar_popup=Choose([ '789', '101112' ])
XPT helloxpt " tips about what this snippet does
XSET x|def=Choose([ 'a', 'b' ])
XSET x|post=Build( '`:' . ( ( { "a" : "foo", "b" : "bar" } )
[ V() ] ) . ':^' )
-`x^=
> But the bad news is that I'd been too lazy(or busy? whatever) to have all
> the functions in doc. You can find them in ftplugin/_common/common.xpt.vim
I looked in there. But, unfortunately, those functions have very
little documentation in the comments of common.xpt.vim, and there are
no examples of how to use most of them. And I don't know enough
vimscript or about the internal workings of xptemplate to figure it
out on my own.
The code you gave above showing how Build() and V() could be used to
transform values that the user gave in to a call to include other
snippets is exactly the sort of example that would make the functions
in common.xpt.vim more useful to the average snippet developer. So
thank you for that!