summaryrefslogtreecommitdiffstats
path: root/doc/unsorted/emacs_snippet.txt
blob: 4eefb4583a8e60b8734603a471474e9c44d6c865 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
.. -*- mode: rst -*-

.. _unsorted-emacs_snippet:

======================
Emacs + YASnippet mode
======================

This page describes using emacs with YASnippet mode with a set of
snippets that allow quick composition of bundles and base files.
More snippets are under development.

#. Download YASnippet from http://code.google.com/p/yasnippet/
#. Install it into your emacs load path (typically ~/.emacs.d/site-lisp)
#. Add YASnippet initialization to your .emacs (remember to re-byte-compile it if needed)

   .. code-block:: cl

       (require 'yasnippet-bundle)

       ;;; Bcfg2 snippet

       (yas/define-snippets 'sgml-mode
       '(
         ("<Bundle" "<Bundle name='${1:bundlename}' version='2.0'>
          $0
       </Bundle>" nil)
         ("<Base" "<Base>
          $0
       </Base>" nil)
         ("<Group" "<Group name='${1:groupname}>
          $0
       </Group>" nil)
         ("<Path" "<Path name='${1:filename}'/>
       $0" nil)
         ("<Service" "<Service name='${1:svcname}'/>
       $0" nil)
         ("<Package" "<Package name='${1:packagename}'/>
       $0" nil)
         ("<Action" "<Action name='${1:name}'/>
       $0" nil)
         ("<Directory" "<Directory name='${1:name}'/>
       $0" nil)
         ("<SymLink" "<SymLink name='${1:name}'/>
       $0" nil)
         ("<Permissions" "<Permissions name='${1:name}'/>
       $0" nil)
       )
       )

#. One quick M-x eval-current-buffer, and this code is enabled

Each of these snippets activates on the opening element, ie <Bundle.
After this string is entered, but before entering a space, press <TAB>,
and the snippet will be expanded. The template will be inserted into
the text with a set of input prompts, which default to overwrite mode
and can be tabbed through.

The code above only works for bundles and base, but will be expanded
to support other xml files as well.