I recently watched this fantastic video on how to use Yasnippet in Emacs.
Can someone explain how to use this snippet?
Specifically, what are the if
and string-match
elisp conditionals/functions doing in regards to the intended use of this snippet?
This snippet is found in Yasnippet c++-mode > printf.
# -*- mode: snippet -*-
# name: printf
# key: printf
# --
printf("${1:%s}\\n"${1:$(if (string-match "%" yas-text) ", " "\);")
}$2${1:$(if (string-match "%" yas-text) "\);" "")}