From 68b0bce76a8fe79c202d7566b545463d8e414d39 Mon Sep 17 00:00:00 2001 From: Joao Tavora Date: Wed, 30 May 2012 17:24:22 +0100 Subject: [PATCH] a little more work, but very little --- doc/manual.org | 77 ++++++++++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 37 deletions(-) diff --git a/doc/manual.org b/doc/manual.org index 8a4c1e9ca..d79b9dc2a 100644 --- a/doc/manual.org +++ b/doc/manual.org @@ -3,14 +3,13 @@ #+OPTIONS: toc:1 #+STARTUP: showall -#+STYLE: +#+STYLE: # External links # #+LINK: smart-snippet http://code.google.com/p/smart-snippet #+LINK: pluskid http://pluskid.lifegoo.org - #+LINK: screencast http://www.youtube.com/watch?v=ZCGmZK4V7Sg #+LINK: docs http://capitaomorte.github.com/yasnippet #+LINK: issues https://github.com/capitaomorte/yasnippet/issues @@ -59,21 +58,25 @@ El-get is a nice way to get the most recent version, too :CUSTOM_ID: import-textmate :END: -Clone the yasnippet repository to `~/.emacs.d/plugins/yasnippet` +Clone the yasnippet repository to =~/.emacs.d/plugins/yasnippet= +#+begin_example cd ~/.emacs.d/plugins/yasnippet git submodule init git submodule update gem install plist trollop rake convert_bundles # will convert ruby, rails and html bundles from drnic +#+end_example Then, in your .emacs file +#+begin_example (add-to-list 'load-path "~/.emacs.d/plugins/yasnippet") (require 'yasnippet) (setq yas/snippet-dirs '("~/.emacs.d/snippets" "~/.emacs.d/extras/imported")) (yas/global-mode 1) +#+end_example Open some rails file (model, app, etc) and start using the textmate snippets. @@ -100,7 +103,8 @@ If you run into problems using YASnippet, or have snippets to contribute, post to the [[forum][yasnippet forum]]. Thank you very much for using YASnippet! * Organizing snippets -** Setting up =yas/snippet-dirs= before calling =yas/global-mode= + +** Setting up =yas/snippet-dirs= Snippet collections are stored in specially organized file hierarchies. These are loaded by YASnippet into *snippet tables* which the triggering mechanism @@ -108,14 +112,15 @@ are loaded by YASnippet into *snippet tables* which the triggering mechanism expanded for you. An emacs variable =yas/snippet-dirs= tells YASnippet which collections to -consider. +consider. It's used when you activate =yas/global-mode= or call =yas/reload-all= +interactively. -If you don't tweak it the default value of =yas/snippet-dirs= considers: +The default considers: - a personal collection that YASnippet decides lives in =~/.emacs.d/snippets= - the bundled collection, taken as a relative path to =yasnippet.el= localtion -You might and probably want to try out more snippet collections though: +Do the following to try out more snippet collections though: #+begin_src emacs-lisp :exports both ;; Develop in ~/emacs.d/mysnippets, but also @@ -132,13 +137,35 @@ Collections appearing earlier in the list shadow any conflicting snippets from collections later in the list. =yas/new-snippet= always stores snippets in the first collection. -# Snippet definitions are put in plain text files. They are arranged -# by sub-directories, and the snippet tables are named after these -# directories. +** Basic organization + +Snippet definitions are stored in plain text files. They are arranged by +sub-directories. The directories name snippet tables, which in turn name +Emacs major names. For example, snippets for =c-mode= are put in the +``c-mode`` sub-directory while + +** The =.yas.parents= file + +It's very useful to have certain modes share snippets between themselves. To do +this, choose a mode subdirectory and place a =.yas-parents= containing a +whitespace-separated list of other mode names. When you reload those modes +become parents of the original mode. -# The name corresponds to the Emacs mode where you want expansion to -# take place. For example, snippets for ``c-mode`` are put in the -# ``c-mode`` sub-directory. +#+begin_example +. +|-- c-mode +| |-- .yas-parents # contains "cc-mode text-mode" +| `-- printf +|-- cc-mode +| |-- for +| `-- while +|-- java-mode +| |-- .yas-parents # contains "cc-mode text-mode" +| `-- println +`-- text-mode + |-- email + `-- time +#+end_example @@ -176,31 +203,7 @@ first collection. -# The ``.yas.parents`` file -# ------------------------- - -# It's very useful to have certain modes share snippets between -# themselves. To do this, choose a mode subdirectory and place a -# ``.yas-parents`` containing a whitespace-separated list of other -# mode names. When you reload those modes become parents of the -# original mode. - -# .. sourcecode:: text -# $ tree -# . -# |-- c-mode -# | |-- .yas-parents # contains "cc-mode text-mode" -# | `-- printf -# |-- cc-mode -# | |-- for -# | `-- while -# |-- java-mode -# | |-- .yas-parents # contains "cc-mode text-mode" -# | `-- println -# `-- text-mode -# |-- email -# `-- time # The ``.yas-make-groups`` file # ----------------------------- -- 2.39.2