mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-14 13:33:04 +00:00
a little more work, but very little
This commit is contained in:
parent
8b7285b640
commit
68b0bce76a
@ -3,14 +3,13 @@
|
|||||||
#+OPTIONS: toc:1
|
#+OPTIONS: toc:1
|
||||||
#+STARTUP: showall
|
#+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
|
# External links
|
||||||
#
|
#
|
||||||
#+LINK: smart-snippet http://code.google.com/p/smart-snippet
|
#+LINK: smart-snippet http://code.google.com/p/smart-snippet
|
||||||
#+LINK: pluskid http://pluskid.lifegoo.org
|
#+LINK: pluskid http://pluskid.lifegoo.org
|
||||||
|
|
||||||
|
|
||||||
#+LINK: screencast http://www.youtube.com/watch?v=ZCGmZK4V7Sg
|
#+LINK: screencast http://www.youtube.com/watch?v=ZCGmZK4V7Sg
|
||||||
#+LINK: docs http://capitaomorte.github.com/yasnippet
|
#+LINK: docs http://capitaomorte.github.com/yasnippet
|
||||||
#+LINK: issues https://github.com/capitaomorte/yasnippet/issues
|
#+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
|
:CUSTOM_ID: import-textmate
|
||||||
:END:
|
: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
|
cd ~/.emacs.d/plugins/yasnippet
|
||||||
git submodule init
|
git submodule init
|
||||||
git submodule update
|
git submodule update
|
||||||
gem install plist trollop
|
gem install plist trollop
|
||||||
rake convert_bundles # will convert ruby, rails and html bundles from drnic
|
rake convert_bundles # will convert ruby, rails and html bundles from drnic
|
||||||
|
#+end_example
|
||||||
|
|
||||||
Then, in your .emacs file
|
Then, in your .emacs file
|
||||||
|
|
||||||
|
#+begin_example
|
||||||
(add-to-list 'load-path
|
(add-to-list 'load-path
|
||||||
"~/.emacs.d/plugins/yasnippet")
|
"~/.emacs.d/plugins/yasnippet")
|
||||||
(require 'yasnippet)
|
(require 'yasnippet)
|
||||||
(setq yas/snippet-dirs '("~/.emacs.d/snippets" "~/.emacs.d/extras/imported"))
|
(setq yas/snippet-dirs '("~/.emacs.d/snippets" "~/.emacs.d/extras/imported"))
|
||||||
(yas/global-mode 1)
|
(yas/global-mode 1)
|
||||||
|
#+end_example
|
||||||
|
|
||||||
Open some rails file (model, app, etc) and start using the textmate snippets.
|
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!
|
to the [[forum][yasnippet forum]]. Thank you very much for using YASnippet!
|
||||||
|
|
||||||
* Organizing snippets
|
* 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
|
Snippet collections are stored in specially organized file hierarchies. These
|
||||||
are loaded by YASnippet into *snippet tables* which the triggering mechanism
|
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.
|
expanded for you.
|
||||||
|
|
||||||
An emacs variable =yas/snippet-dirs= tells YASnippet which collections to
|
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=
|
- a personal collection that YASnippet decides lives in =~/.emacs.d/snippets=
|
||||||
- the bundled collection, taken as a relative path to =yasnippet.el= localtion
|
- 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
|
#+begin_src emacs-lisp :exports both
|
||||||
;; Develop in ~/emacs.d/mysnippets, but also
|
;; 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
|
collections later in the list. =yas/new-snippet= always stores snippets in the
|
||||||
first collection.
|
first collection.
|
||||||
|
|
||||||
# Snippet definitions are put in plain text files. They are arranged
|
** Basic organization
|
||||||
# by sub-directories, and the snippet tables are named after these
|
|
||||||
# directories.
|
|
||||||
|
|
||||||
# The name corresponds to the Emacs mode where you want expansion to
|
Snippet definitions are stored in plain text files. They are arranged by
|
||||||
# take place. For example, snippets for ``c-mode`` are put in the
|
sub-directories. The directories name snippet tables, which in turn name
|
||||||
# ``c-mode`` sub-directory.
|
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
|
# The ``.yas-make-groups`` file
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user