Comment #5 on issue 31 by joaotavora: Executing lisp code after TAB
http://code.google.com/p/yasnippet/issues/detail?id=31
Won't take action on this enhancement issue until further feedback.
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings
Mirror transformations are basically functions of the text (text or
yas/text variable) that is present on the field they mirror. YASnippet
wasn't designed to handle stuff such as side effects, which is one of
the things that might make your intention work.
Consider the following *workaround*, check if it works
`(progn (setq my-reftex-cache nil) "")`
\section{${1:"Titel der Tour"$(if yas/moving-away-p
(progn (setq my-reftex-cache (reftex-label nil
'dont-insert))
(yas/update-mirrors snippet))
(setq my-reftex-cache nil))}}%
\index{${1:$(or my-reftex-cache
"waiting...")}}%
The my-reftex-cache variable implements the side-effect communication
between the field and the mirror. Then you need the first progn line
to initialize the variable. Then you need a **really** dirty hack
where you force a mirror update. This is not guaranteed to work in the
future (or in the present, for that matter), since it uses internal
yasnippet workings which might change in the future.
But I ask you if you'd rather not use this:
\section{${1:"Titel der Tour"}}%
\index{${2:"waiting..."$(unless yas/modified-p (reftex-label nil 'dont-
insert))}}%
The only *inconvenient * here is that you get a chance to change the
value inserted by reftex-label. Other than that, it's much cleaner,
and is the "recommended" way.
Naturally, I didn't think of your scenario when I designed this
feature. Its possible to make the first alternative cleaner in the
future, I'll leave the issue open, maybe retitle it.
Bye,
J
Comment #6 on issue 31 by joaotavora: Executing lisp code after TAB
http://code.google.com/p/yasnippet/issues/detail?id=31
See thread
http://groups.google.com/group/smart-snippet/browse_thread/thread/282a90a118e1b662.
Additionally, the following snippet can help the drawback of the second
alternative:
\section{${1:"Titel der Tour"}}%
\index{${2:"waiting..."$(unless yas/modified-p (prog1 (reftex-label
nil 'dont-insert)
(yas/schedule-field-skip)))}}%
$0
and some supporting elisp code...
(defun yas/schedule-field-skip ()
(add-hook 'post-command-hook 'yas/field-skip-once 'append 'local))
(defun yas/field-skip-once ()
(condition-case err
(yas/next-field)
(error nil))
(remove-hook 'post-command-hook 'yas/field-skip-once 'local))