Back-ticks surrounding the elisp
code to be evaluated are required. The built-in variable yas-selected-text
stores the text of the selected region, which can be used to reinsert the same text during the snippet creation. Four (4) backslashes are needed for every one (1) backslash.
# -*- mode: snippet -*-
# contributor: lawlist
# key: bold
# name: bold
# binding: TAB <f6>
# --
`(if (region-active-p)
(concat
"{\\\\bf "
yas-selected-text
"}")
"{\\\\bf $1}")`