Add new function yas-lookup-snippet

* yasnippet.el (yas-lookup-snippet): New function.
(yas--get-snippet-tables, yas--modes-to-activate): Add optional mode
parameter.
* yasnippet-tests.el (snippet-lookup): New test for yas-lookup-snippet.
* doc/snippet-expansion.org (Expanding from emacs-lisp code): Mention
  yas-lookup-snippet.
This commit is contained in:
Noam Postavsky
2015-08-03 10:36:46 -04:00
parent 5ebf347392
commit 7bce1a6473
3 changed files with 44 additions and 11 deletions

View File

@@ -104,18 +104,21 @@ prefer.
Sometimes you might want to expand a snippet directly from your own
elisp code. You should call [[sym:yas-expand-snippet][=yas-expand-snippet=]] instead of
[[sym:yas-expand][=yas-expand=]] in this case.
[[sym:yas-expand][=yas-expand=]] in this case. [[sym:yas-expand-snippet][=yas-expand-snippet=]] takes a string in
snippet template syntax, if you want to expand an existing snippet you
can use [[sym:yas-lookup-snippet][=yas-lookup-snippet=]] to find its contents by name.
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:
candidates doesn't affect expansion (the condition system does affect
[[sym:yas-lookup-snippet][=yas-lookup-snippet=]] though). 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.
See the internal documentation on [[sym:yas-expand-snippet][=yas-expand-snippet=]] and
[[sym:yas-lookup-snippet][=yas-lookup-snippet=]] for more information.
* Controlling expansion