Is it possible to have a history for the value of a yasnippet field? When I expand a second time a snippet like \begin{${1:environment}}
I would like to get as suggestion the value I've used for $1
in the last expansion.
1 Answer
I've found a solution with a pseudo-field in which I save the previous value and jump to the next. It feels ugly and I hope someone can give a better answer.
# -*- mode: snippet -*-
# name: Environment
# key: env
# --
\begin{${1:`(or (and (boundp 'last-snippet-environment) last-snippet-environment) "environment")`}}
$0${2:$$((lambda ()
(set (make-local-variable 'last-snippet-environment) (yas-field-value 1))
(yas-next-field)
""
))}
\end{$1}