a little more work, but very little

This commit is contained in:
Joao Tavora 2012-05-30 17:24:22 +01:00
parent 8b7285b640
commit 68b0bce76a

View File

@ -3,14 +3,13 @@
#+OPTIONS: toc:1
#+STARTUP: showall
#+STYLE: <link rel="stylesheet" type="text/css" href="assets/stylesheet.css" />
#+STYLE: <link rel="stylesheet" type="text/css" href="stylesheets/styles.css" />
# 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
# 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.
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.
#+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
# -----------------------------