Close #937: Officially support automatically moving to next field

* yasnippet-tests.el (auto-next-field): New test.
(yas-saving-variables): Move up in the file.

* yasnippet.el (yas--auto-next): New helper.
(yas-auto-next): New user-visible snippet helper.

* doc/snippet-development.org (Choosing fields value from a list
and other tricks): Add mention of yas-auto-next.
This commit is contained in:
João Távora
2018-05-16 13:22:27 +01:00
parent 5a29fe67d7
commit 4f78d03f85
3 changed files with 49 additions and 6 deletions

View File

@@ -420,8 +420,19 @@ The [[sym:yas-choose-value][=yas-choose-value=]] does this work for you. For exa
</div>
#+END_SRC
See the definition of [[sym:yas-choose-value][=yas-choose-value=]] to see how it was written using
the two variables.
See the definition of [[sym:yas-choose-value][=yas-choose-value=]] to see how it was written
using the two variables. If you're really lazy :) and can't spare a
tab keypress, you can automatically move to the next field (or exit)
after choosing the value with [[sym:yas-auto-next][=yas-auto-next=]]. The snippet above
becomes:
#+BEGIN_SRC snippet
<div align="${2:$$(yas-auto-next
(yas-choose-value
'("right" "center" "left")))}">
$0
</div>
#+END_SRC
Here's another use, for LaTeX-mode, which calls reftex-label just as you
enter snippet field 2. This one makes use of [[sym:yas-modified-p][=yas-modified-p=]] directly.