yasnippet.org 400 B

Embedding elisp inside yasnippets

Make a yasnippet expand around selected text.


  # -*- mode: snippet -*-
  # name: <example
  # key: <example
  # --
   `(if (region-active-p)
   (concat "#+BEGIN_EXAMPLE\n" yas-selected-text "#+END_EXAMPLE") )
   (concat "#+BEGIN_EXAMPLE\n$0\n#+END_EXAMPLE" )`