]> code.delx.au - gnu-emacs-elpa/blob - README.mdown
docfix: add the workaround for using yasnippet as a non-global minor mode. See issue...
[gnu-emacs-elpa] / README.mdown
1 # Intro
2
3 **YASnippet** is a template system for Emacs. It allows you to type an
4 abbreviation and automatically expand it into function
5 templates. Bundled language templates includes: C, C++, C#, Perl,
6 Python, Ruby,
7
8 SQL, LaTeX, HTML, CSS and more. The snippet syntax is inspired from
9 [TextMate's][textmate-snippets] syntax, you can even
10 [import][import-docs] most TextMate templates to YASnippet. Watch
11 [a demo on YouTube][youtube-demo] or download a
12 [higher resolution version][high-res-demo]
13
14 [textmate-snippets]: http://manual.macromates.com/en/snippets
15 [import-docs]: http://yasnippet.googlecode.com/svn/trunk/doc/snippet-development.html#importing-textmate-snippets
16 [youtube-demo]: http://www.youtube.com/watch?v=ZCGmZK4V7Sg
17 [high-res-demo]: http://yasnippet.googlecode.com/files/yas_demo.avi
18
19 # Installation
20
21 ## Install the most recent version
22
23 Clone this repository somewhere
24
25 $ cd ~/.emacs.d/plugins
26 $ git clone https://github.com/capitaomorte/yasnippet
27
28 Add the following in your `.emacs` file:
29
30 (add-to-list 'load-path
31 "~/.emacs.d/plugins/yasnippet")
32 (require 'yasnippet)
33 (yas/global-mode 1)
34
35 Add your own snippets to `~/.emacs.d/snippets` by placing files there or invoking `yas/new-snippet`.
36
37 ## Install yasnippet with el-get
38
39 El-get is a nice way to get the most recent version, too
40
41 See https://github.com/dimitri/el-get for instructions
42
43 ## Use `yas/minor-mode` on a per-buffer basis
44
45 To use yasnippet as a non-global minor mode, replace `(yas/global-mode 1)` with
46 `(yas/reload-all)` to load the snippet tables. Then add a call to
47 `(yas/minor-mode)` to the major-modes where you to enable yasnippet.
48
49 (add-hook 'prog-mode-hook
50 '(lambda ()
51 (yas/minor-mode)))
52
53 # Contributing snippets
54
55 Please do not ask me to add snippets to the default collection under
56 `/snippets`. This is considered frozen and by customizing
57 `yas/snippet-dirs` you can point yasnippet to good snippet collections
58 out there.
59
60 There is a tool `extras/textmate-import.rb` than can import many
61 actual Textmate snippets and there are
62 `extras/imported/*-mode/.yas-setup.el` files that can help it with the
63 more difficult importation.
64
65 I'm focusing on developping `textmate-import.rb` tool and the
66 `yas-setup.el` files. In the future `/snippets` snippets will be
67 deprecated and replaced with `extras/imported`.
68
69 Follow through the following example to start using these snippets for
70 rails development. It will convert `ruby`, `rails` and `html` bundles
71 from drnic's github repositories based on corresponding
72 `.yas-setup.el` files.
73
74 ## Using imported textmate snippets (rails example)
75
76 After cloning this repository to `~/.emacs.d/plugins/yasnippet`
77
78 cd ~/.emacs.d/plugins/yasnippet
79 git submodule init
80 git submodule update
81 gem install plist trollop
82 rake convert_bundles # will convert ruby, rails and html bundles from drnic
83
84 Then, in your .emacs file
85
86 (add-to-list 'load-path
87 "~/.emacs.d/plugins/yasnippet")
88 (require 'yasnippet)
89 (setq yas/snippet-dirs '("~/.emacs.d/snippets" "~/.emacs.d/plugins/yasnippet/extras/imported"))
90 (yas/global-mode 1)
91
92 Open some rails file (model, app, etc) and start using the textmate snippets.
93 Note thqt in the example above we abandon the default snippet collection on
94 `~/.emacs.d/plugins/yasnippet/snippets`
95
96 # Documentation, issues, etc
97
98 Please refer to the comprehensive [documentation] [docs] for full customization
99 and support. If you find a bug, please report it on
100 [the GitHub issue tracker][issues]. (please **do not** submit new issues to the old
101 [googlecode tracker][googlecode tracker])
102
103 If you run into problems using YASnippet, or have snippets to contribute, post
104 to the [yasnippet google group][forum]. Thank you very much for using YASnippet!
105
106 [docs]: http://capitaomorte.github.com/yasnippet/
107 [issues]: https://github.com/capitaomorte/yasnippet/issues
108 [googlecode tracker]: http://code.google.com/p/yasnippet/issues/list
109 [forum]: http://groups.google.com/group/smart-snippet
110
111