branch: master commit 7b8242473558f3b26eb893e97bda8c5532a0dbd1 Author: Noam Postavsky <npost...@users.sourceforge.net> Commit: Noam Postavsky <npost...@users.sourceforge.net>
move index.org subsection into snippet-expansion.org --- doc/index.org | 36 ------------------------------- doc/snippet-expansion.org | 52 ++++++++++++++++++++++++++------------------- 2 files changed, 30 insertions(+), 58 deletions(-) diff --git a/doc/index.org b/doc/index.org index c4bb052..54ec232 100644 --- a/doc/index.org +++ b/doc/index.org @@ -127,42 +127,6 @@ If you run into problems using YASnippet, or have snippets to contribute, post to the [[http://groups.google.com/group/smart-snippet][yasnippet forum]]. Thank you very much for using YASnippet! - -* Expanding Snippets - - :PROPERTIES: - :CUSTOM_ID: expand-snippets - :END: - - This section describes how YASnippet chooses snippets for expansion at point. - - Maybe, you'll want some snippets to be expanded in a particular - mode, or only under certain conditions, or be prompted using - -** Triggering expansion - - To make a snippet expand after the cursor: - - * Type the snippet's *trigger key* then calling [[sym:yas-expand][=yas-expand=]]. It's bound to - =TAB= and =<tab>= by default, to change it use - - #+begin_src emacs-lisp :exports code - (define-key yas-minor-mode-map (kbd "<tab>") nil) - (define-key yas-minor-mode-map (kbd "TAB") nil) - (define-key yas-minor-mode-map (kbd "<the new key>") 'yas-expand) - #+end_src - - * Use the snippet's *keybinding*. - - * Call [[sym:yas-insert-snippet][=yas-insert-snippet=]] (use =M-x - yas-insert-snippet== or its keybinding =C-c & C-s=). - - * By expanding directly from the "YASnippet" menu in the menu-bar - - * Using hippie-expand - - * Use m2m's excellent auto-complete - # Local Variables: # mode: org # fill-column: 80 diff --git a/doc/snippet-expansion.org b/doc/snippet-expansion.org index 75efe86..af0fe21 100644 --- a/doc/snippet-expansion.org +++ b/doc/snippet-expansion.org @@ -1,38 +1,49 @@ +#+SETUPFILE: org-setup.inc + * Expanding snippets + This section describes how YASnippet chooses snippets for expansion at point. + + Maybe, you'll want some snippets to be expanded in a particular + mode, or only under certain conditions, or be prompted using + ** Triggering expansion -You can use YASnippet to expand snippets in different ways: + You can use YASnippet to expand snippets in different ways: -- By typing an abbrev, the snippet /trigger key/, and then pressing the - key defined in =yas-trigger-key= (which defaults to "TAB"). This - works in buffers where the minor mode =yas-minor-mode= is active; + - When =yas-minor-mode= is active: + - Type the snippet's *trigger key* then calling [[sym:yas-expand][=yas-expand=]] + (bound to =TAB= by default). -- By invoking the command =yas-insert-snippet= (either by typing - =M-x yas-insert-snippet= or its keybinding). This does /not/ require - =yas-minor-mode= to be active. + - Use the snippet's *keybinding*. -- By using the keybinding associated with an active snippet. This also - requires =yas-minor-mode= to be active; + - By expanding directly from the "YASnippet" menu in the menu-bar -- By expanding directly from the "YASnippet" menu in the menu-bar + - Using hippie-expand -- By using hippie-expand + - Call [[sym:yas-insert-snippet][=yas-insert-snippet=]] (use =M-x yas-insert-snippet== or its + keybinding =C-c & C-s=). -- Expanding from emacs-lisp code + - Use m2m's excellent auto-complete + TODO: example for this + + - Expanding from emacs-lisp code *** Trigger key -When =yas-minor-mode= is enabled, the keybinding taken from -=yas-trigger-key= will take effect. +=yas-expand= tries to expand a /snippet abbrev/ (also known as +/snippet key/) before point. -=yas-trigger-key= invokes =yas-expand=, which tries to expand a /snippet -abbrev/ (also known as /snippet key/) before point. +When =yas-minor-mode= is enabled, it binds [[sym:yas-expand][=yas-expand=]] to =TAB= and +=<tab>= by default, however, you can freely set it to some other key: -The default key is ="TAB"=, however, you can freely set it to some other -key. +#+begin_src emacs-lisp :exports code + (define-key yas-minor-mode-map (kbd "<tab>") nil) + (define-key yas-minor-mode-map (kbd "TAB") nil) + (define-key yas-minor-mode-map (kbd "<the new key>") 'yas-expand) +#+end_src -[[images/minor-mode-indicator.png]] +[[./images/minor-mode-indicator.png]] To enable the YASnippet minor mode in all buffers globally use the command =yas-global-mode=. @@ -41,9 +52,6 @@ When you use =yas-global-mode= you can also selectively disable YASnippet in some buffers by setting the buffer-local variable =yas-dont-active= in the buffer's mode hook. -Trouble when using or understanding the =yas-trigger-key= is easily the -most controversial issue in YASsnippet. See the [[faq.html][FAQ]]. - **** Fallback bahaviour =yas-fallback-behaviour= is a customization variable bound to