Tab fields after arbitrary elisp

31 views
Skip to first unread message

Ross Donaldson

unread,
Oct 30, 2014, 4:48:24 PM10/30/14
to smart-...@googlegroups.com
Hullo all --

First off: yasnippet has saved me so much time. Thanks to all the creators! Great stuff.

Question: I want to insert text based on evaluating a conditional expression, and then I want a tab field. I imagine this working like so (example imagines YAML mode, but I doubt that matters):

field_one: ${1:default}
field_two
: ${2:default}
`(if(my-predicate-fn)
   "field_three_a: "
   "field_three_b: ")`
$3
$0

But this doesn't work at all -- field $3 is skipped every time. What don't I grok about this? 

Thanks!

--Ross

João Távora

unread,
Oct 31, 2014, 7:50:39 AM10/31/14
to Ross Donaldson, smart-...@googlegroups.com
Ross Donaldson <gas...@gmail.com> writes:

> Hullo all --
>
> First off: yasnippet has saved me so much time. Thanks to all the creators!
> Great stuff.
>
> Question: I want to insert text based on evaluating a conditional
> expression, and then I want a tab field. I imagine this working like so
> (example imagines YAML mode, but I doubt that matters):
>
> field_one: ${1:default}
> field_two: ${2:default}
> `(if(my-predicate-fn)
> "field_three_a: "
> "field_three_b: ")`$3
> $0


This seems to be the same question as your previous message (if it's not
please tell me).

Anyway, your example looks fine. I don't know what `my-predicate-fn`
does, but I've just tested something similar which works fine:

${1:foo}
`(if (zerop (random 2)) "bar: " "baz: ")`$2
$0

Can you open an issue in https://github.com/capitaomorte/yasnippet/issues ?

Be sure to read the README.md for guidelines when reporting issues
though (I need to be able to reproduce it just like it happened to you.)

João
Reply all
Reply to author
Forward
0 new messages