mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 13:13:03 +00:00
Clarify behavior of mirror transforms
* doc/snippet-development.org (mirror-fields): Note that all mirros are updated when any field is changed. (mirror-transformations): Add an example of a mirror taking values from multiple fields.
This commit is contained in:
parent
b0aa5c2816
commit
4755aa9781
@ -284,9 +284,9 @@ The number can be omitted if you don't want to create [[mirrors-fields][mirrors]
|
|||||||
|
|
||||||
** Mirrors <<mirrors-fields>>
|
** Mirrors <<mirrors-fields>>
|
||||||
|
|
||||||
We refer the tab stops with placeholders as a /field/. A field can have
|
We refer the tab stops with placeholders as a /field/. A field can
|
||||||
mirrors. Its mirrors will get updated when you change the text of a
|
have mirrors. *All* mirrors get updated whenever you update any field
|
||||||
field. Here's an example:
|
text. Here's an example:
|
||||||
|
|
||||||
#+BEGIN_SRC snippet
|
#+BEGIN_SRC snippet
|
||||||
\begin{${1:enumerate}}
|
\begin{${1:enumerate}}
|
||||||
@ -362,6 +362,20 @@ is not. Here's an snippet for rst title:
|
|||||||
$0
|
$0
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
|
Note that a mirror with a transform is not restricted to the text of
|
||||||
|
the field it is mirroring. By making use of [[sym:yas-field-value][=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:
|
||||||
|
|
||||||
|
#+BEGIN_SRC snippet
|
||||||
|
(format "${1:formatted %s}" "${2:value}")
|
||||||
|
=> "${1:$(ignore-errors (format (yas-field-value 1) (yas-field-value 2)))}"
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
To keep the example simple, it uses =ignore-errors= to suppress errors
|
||||||
|
due to incomplete format codes.
|
||||||
|
|
||||||
** Fields with transformations
|
** Fields with transformations
|
||||||
|
|
||||||
From version 0.6 on, you can also have lisp transformation inside
|
From version 0.6 on, you can also have lisp transformation inside
|
||||||
|
Loading…
x
Reference in New Issue
Block a user