# Yasnippet: Prompting the user for information to fill in a latex snippet

I write a snippet to insert a theorem environment into a latex document, based upon some snippets created by another project: https://github.com/madsdk/yasnippets-latex .

In the snippet below, the snippet is inserted and emacs prompts the user to input some information for the label. What I wanted to do was get a second prompt ${2} that asks the use for the name of the theorem--which will go into the second marked item in the snippet. # -*- mode: snippet -*- # contributor: kb # key: thrm # group: math # name: theorem # -- \begin{thrm}[${2}]
\label{${1:"waiting for reftex-label call..."$(unless yas/modified-p (reftex-label nil 'dont-insert))}}
$0 \end{thrm}  I tried to emulate input for ${1} in ${2}, but the snippet failed to compile or execute. I suspect I just need a different function that takes an input instead of reftex-label but I am not familiar enough with elisp to know which one. Any suggestions? ## 1 Answer The solution is to use the elisp read-string function. You can swap out the reftex-label stuff and use the more generic function when you want. Here is an example of a snippet that will take some input text and then italicize it in latex. # -*- mode: snippet -*- # key: italicize # group: environments # name: italicize # -- \textit{${1:(read-string "Enter text: ")}} $0  As for the original snippet in the OP, you could try this. # -*- mode: snippet -*- # contributor: kb # key: thrm # group: math # name: theorem # -- \begin{thrm}[${2:(read-string "Enter description")}]
\label{${1:"waiting for reftex-label call..."$(unless yas/modified-p (reftex-label nil 'dont-insert))}}
\$0
\end{thrm}