If the value of an ${n: -construct starts with and contains $( , then it is interpreted as a mirror for field n with a transformation. The mirror's text content is calculated according to this transformation, which is Emacs-lisp code that gets evaluated in an environment where the variable yas-text is bound to the text content (string) contained in the field n . Here's an example for Objective-C:

- ( ${ 1 : id } ) ${ 2 : foo } { return $ 2 ; } - (void)set ${ 2 : $( capitalize yas-text) } :( $ 1 )aValue { [ $ 2 autorelease]; $ 2 = [aValue retain]; } $ 0

Look at ${2:$(capitalize yas-text)} , it is a mirror with transformation instead of a field. The actual field is at the first line: ${2:foo} . When you type text in ${2:foo} , the transformation will be evaluated and the result will be placed there as the transformed text. So in this example, if you type "baz" in the field, the transformed text will be "Baz". This example is also available in the screencast.

Another example is for rst-mode . In reStructuredText, the document title can be some text surrounded by " = " below and above. The " = " should be at least as long as the text. So

===== Title =====

is a valid title but

=== Title ===

is not. Here's an snippet for rst title:

${ 1 : $( make-string (string-width yas-text) ?\=) } ${ 1 : Title } ${ 1 : $( make-string (string-width yas-text) ?\=) } $ 0

Note that a mirror with a transform is not restricted to the text of the field it is mirroring. By making use of yas-field-value , a mirror can look at any of the snippet's field (as mentioned above, all mirrors are updated when any field is updated). Here is an example which shows a "live" result of calling format:

(format "${ 1 :formatted %s}" "${ 2 :value}" ) => "${ 1 :$(ignore-errors (format (yas-field-value 1) (yas-field-value 2)))}"