1

Consider sample below:

SERVER-1
[connection] 192.168.0.1 success
[connection] 192.168.0.2 failed
[disconnect] 192.168.0.3 pending
[connection] 192.168.0.4 success

but [${1:connection}] ${2:192.168.0.${3:1}} ${4:success} only work for one placeholder (doesn't support alternative placeholders),

Does ya-snippet support syntax like ${1:connection OR disconnect} to give more alternative placeholders? (that's when you cursor is in placeholder, you hit tab then give you next placeholder until the last, yeah this is inefficient when you have list of choices, so consider the alternative implement below instead...)

or maybe integrate elisp powerful function like

${1:$$(popup-prompt '("connection" "disconnect"))} prompt for completion, i guess this function exist...

2
  • yas-choose-value perhaps?
    – npostavs
    Nov 20, 2017 at 4:03
  • yeah, that's what i want, thanks :) Nov 20, 2017 at 5:58

1 Answer 1

0

See Choosing fields value from a list and other tricks:

As mentioned, the field transformation is invoked just after you enter the field, and with some useful variables bound, notably yas-modified-p and yas-moving-away-p. Because of this feature you can place a transformation in the primary field that lets you select default values for it.

The function yas-choose-value does this work for you. For example:

<div align="${2:$$(yas-choose-value '("right" "center" "left"))}">  
  $0
</div>

See the definition of yas-choose-value to see how it was written using the two variables.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.