I'm writing a snippet (for Go) and would like to have a field conditionally transformed when I move to the next field. Specifically, I want the field empty if I leave it unedited, and enclosed in parentheses if I leave it edited.
My unsuccessful snippet, expressing what I want but failing to transform an edited field:
func ${1:$$(when (and yas-modified-p yas-moving-away-p)
(concat "(" yas-text ")"))} FuncName
What I want is, that when typing t Type
in the field, the snippet would expand as such:
func (t Type) FuncName
and when skipping over the field unedited it would expand like this:
func FuncName
I know that the condition executes as one would expect, because if I change (concat ...)
to (message "XXX")
, I see the trace printed in the mini buffer, but I can't figure out why my transformation doesn't work.