]> code.delx.au - gnu-emacs-elpa/blob - doc/faq.org
convert old rst manuals to org mode
[gnu-emacs-elpa] / doc / faq.org
1 * Frequently Asked Questions
2
3 ** Why is there an extra newline?
4
5 If you have a newline at the end of the snippet definition file, then
6 YASnippet will add a newline when you expanding a snippet. Please don't
7 add a newline at the end if you don't want it when you saving the
8 snippet file.
9
10 Note some editors will automatically add a newline for you. In Emacs, if
11 you set =require-final-newline= to =t=, it will add the final newline
12 for you automatically.
13
14 ** Why doesn't TAB expand a snippet?
15
16 First check the mode line to see if there's =yas=. If not, then try
17 =M-x yas-minor-mode= to manually turn on the minor mode and try to
18 expand the snippet again. If it works, then, you can add the following
19 code to your =.emacs= /before/ loading YASnippet:
20
21 where =the-major-mode= is the major mode in which =yas-minor-mode= isn't
22 enabled by default.
23
24 From YASnippet 0.6 you can also use the command =M-x yas-global-mode= to
25 turn on YASnippet automatically for /all/ major modes.
26
27 If =yas-minor-mode= is on but the snippet still not expanded. Then try
28 to see what command is bound to the =TAB= key: press =C-h k= and then
29 press =TAB=. Emacs will show you the result.
30
31 You'll see a buffer prompted by Emacs saying that
32 =TAB runs the command ...=. Alternatively, you might see
33 =<tab> runs the command ...=, note the difference between =TAB= and
34 =<tab>= where the latter has priority. If you see =<tab>= bound to a
35 command other than =yas-expand=, (e.g. in =org-mode=) you can try the
36 following code to work around:
37
38 replace =org-mode-hook= and =org-mode-map= with the major mode hook you
39 are dealing with (Use =C-h m= to see what major mode you are in).
40
41 As an alternative, you can also try
42
43 To /advise/ the modes indentation function bound to TAB, (in this case
44 =ruby-indent-line=) to first try to run =yas-expand=.
45
46 If the output of =C-h k RET <tab>= tells you that =<tab>= is indeed
47 bound to =yas-expand= but YASnippet still doesn't work, check your
48 configuration and you may also ask for help on the
49 [[http://groups.google.com/group/smart-snippet][discussion group]]. See
50 this particular
51 [[http://code.google.com/p/yasnippet/issues/detail?id=93&can=1][thread]]
52 for quite some solutions and alternatives.
53
54 Don't forget to attach the information on what command is bound to TAB
55 as well as the mode information (Can be obtained by =C-h m=).
56
57 ** Why doesn't TAB navigation work with flyspell
58
59 A workaround is to inhibit flyspell overlays while the snippet is
60 active:
61
62 This is apparently related to overlay priorities. For some reason, the
63 =keymap= property of flyspell's overlays always takes priority over the
64 same property in yasnippet's overlays, even if one sets the latter's
65 =priority= property to something big. If you know emacs-lisp and can
66 solve this problem, drop a line in the
67 [[http://groups.google.com/group/smart-snippet][discussion group]].
68
69 ** How do I turn off the minor mode where in some buffers
70
71 The best way, since version 0.6.1c, is to set the default value of the
72 variable =yas-dont-activate= to a lambda function like so:
73
74 This is also the default value starting for that version. It skips the
75 minor mode in buffers where it is not applicable (no snippet tables),
76 but only once you have setup your yas-root-directory.
77
78 ** How do I define an abbrev key containing characters not supported by
79 the filesystem?
80
81 - *Note*: This question applies if you're still defining
82 snippets :: whose key /is/ the filename. This is behavior stil
83 provided by version 0.6 for backward compatibilty, but is somewhat
84 deprecated...
85
86 For example, you want to define a snippet by the key =<= which is not a
87 valid character for filename on Windows. This means you can't use the
88 filename as a trigger key in this case.
89
90 You should rather use the =# key:= directive to specify the key of the
91 defined snippet explicitly and name your snippet with an arbitrary valid
92 filename, =lt.yasnippet= for example, using =<= for the =# key:=
93 directive: