branch: master
commit 08a44b43dc7074dbf4baed538849bbfaafc81908
Author: Noam Postavsky <[email protected]>
Commit: Noam Postavsky <[email protected]>
add code examples for snippet-expansion.rst
pandoc org -> rst drops them
---
doc/snippet-expansion.org | 27 ++++++++++++++++++++++++++-
1 files changed, 26 insertions(+), 1 deletions(-)
diff --git a/doc/snippet-expansion.org b/doc/snippet-expansion.org
index 54a212f..53e6ad5 100644
--- a/doc/snippet-expansion.org
+++ b/doc/snippet-expansion.org
@@ -109,6 +109,10 @@ As with expanding from the menubar, the condition system
and multiple
candidates doesn't affect expansion. In fact, expanding from the
YASnippet menu has the same effect of evaluating the follow code:
+#+BEGIN_SRC emacs-lisp
+ (yas-expand-snippet template)
+#+END_SRC
+
See the internal documentation on
[[sym:yas-expand-snippet][=yas-expand-snippet=]] for more
information.
@@ -144,7 +148,15 @@ In particular, the following things matter:
Use [[#yas-activate-extra-mode][=yas-activate-extra-mode=]] to consider
snippet tables whose name
does not correspond to a major mode. Typically, you call this from
- a minor mode hook.
+ a minor mode hook, for example:
+
+#+BEGIN_SRC emacs-lisp
+ ;; When entering rinari-minor-mode, consider also the snippets in the
+ ;; snippet table "rails-mode"
+ (add-hook 'rinari-minor-mode-hook
+ #'(lambda ()
+ (yas-activate-extra-mode 'rails-mode)))
+#+END_SRC
- Buffer-local
[[sym:yas-buffer-local-condition][=yas-buffer-local-condition=]] variable
@@ -206,6 +218,15 @@ story and look at the rules:
In the mentioned scenario, set
[[sym:yas-buffer-local-condition][=yas-buffer-local-condition=]] like this
+#+BEGIN_SRC emacs-lisp
+ (add-hook 'python-mode-hook
+ (lambda ()
+ (setq yas-buffer-local-condition
+ '(if (python-in-string/comment)
+ '(require-snippet-condition . force-in-comment)
+ t))))
+#+END_SRC
+
... and specify the condition for a snippet that you're going to expand
in comment to be evaluated to the symbol =force-in-comment=. Then it can
be expanded as you expected, while other snippets like =if= still can't
@@ -225,6 +246,10 @@ You can customize it with
=M-x customize-variable RET yas-prompt-functions RET=. Alternatively you
can put in your emacs-file:
+#+BEGIN_SRC emacs-lisp
+ (setq yas-prompt-functions '(yas-x-prompt yas-dropdown-prompt))
+#+END_SRC
+
Currently there are some alternatives solution with YASnippet.
**** Use the X window system