[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 4755aa9 49/51: Clarify behavior of mirror transforms
From: |
Noam Postavsky |
Subject: |
[elpa] master 4755aa9 49/51: Clarify behavior of mirror transforms |
Date: |
Sun, 13 May 2018 13:11:49 -0400 (EDT) |
branch: master
commit 4755aa9781653d4909fd373ae51afa3559be419a
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>
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.
---
doc/snippet-development.org | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/doc/snippet-development.org b/doc/snippet-development.org
index a2eec85..9112cd0 100644
--- a/doc/snippet-development.org
+++ b/doc/snippet-development.org
@@ -284,9 +284,9 @@ The number can be omitted if you don't want to create
[[mirrors-fields][mirrors]
** Mirrors <<mirrors-fields>>
-We refer the tab stops with placeholders as a /field/. A field can have
-mirrors. Its mirrors will get updated when you change the text of a
-field. Here's an example:
+We refer the tab stops with placeholders as a /field/. A field can
+have mirrors. *All* mirrors get updated whenever you update any field
+text. Here's an example:
#+BEGIN_SRC snippet
\begin{${1:enumerate}}
@@ -362,6 +362,20 @@ is not. Here's an snippet for rst title:
$0
#+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
From version 0.6 on, you can also have lisp transformation inside
- [elpa] master 8b421bc 20/51: Reinstate the old debug behaviour for yas-tryout-snippet, (continued)
- [elpa] master 8b421bc 20/51: Reinstate the old debug behaviour for yas-tryout-snippet, Noam Postavsky, 2018/05/13
- [elpa] master 074d670 26/51: Add yasnippet-unload-function, Noam Postavsky, 2018/05/13
- [elpa] master d364425 38/51: * yasnippet.el (yas-field-value): Fix docstring., Noam Postavsky, 2018/05/13
- [elpa] master 05ac1da 31/51: ; yasnippet-tests.el (yas-no-memory-of-bad-snippet): Fix docstring., Noam Postavsky, 2018/05/13
- [elpa] master 3032337 37/51: Improve rendering of docstrings in manual's reference section, Noam Postavsky, 2018/05/13
- [elpa] master ae95810 43/51: ; Try to get more info about 873/919, Noam Postavsky, 2018/05/13
- [elpa] master 15761e8 41/51: Adjust previous fix, Noam Postavsky, 2018/05/13
- [elpa] master 0afc638 35/51: Fix docs for new org mode, Noam Postavsky, 2018/05/13
- [elpa] master 1668607 46/51: Don't add to disabled undo list, Noam Postavsky, 2018/05/13
- [elpa] master f9231b0 47/51: Work around Emacs Bug#30931 (Misc_Free in undo list), Noam Postavsky, 2018/05/13
- [elpa] master 4755aa9 49/51: Clarify behavior of mirror transforms,
Noam Postavsky <=
- [elpa] master e261832 36/51: Add some styling to doc, improve top menu, Noam Postavsky, 2018/05/13
- [elpa] master 58b88d8 39/51: Merge: doc style improvements, Noam Postavsky, 2018/05/13
- [elpa] master e64297e 51/51: * packages/yasnippet: Merge version 0.13.0 from upstream., Noam Postavsky, 2018/05/13