YASnippet
The :binding property is much more powerful than I
expected!
# type: command
# key: nil
# name: mathcal
# binding: 'c
# --
(progn
(progn
(let
((sym (thing-at-point 'symbol t))
(bounds (bounds-of-thing-at-point 'symbol)))
(delete-region (car bounds) (cdr bounds))
(insert (concat "\\mathcal{" sym "}")))))
This replaces the symbol at the point with
\mathcal{sym} whenever the user hits 'c.