mirror of
https://github.com/joaotavora/yasnippet.git
synced 2026-02-04 06:32:24 +00:00
Automatic documentation update.
From 0.12.2
This commit is contained in:
155
faq.html
155
faq.html
@@ -4,7 +4,6 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
||||
<head>
|
||||
<title>Frequently Asked Questions</title>
|
||||
<!-- 2016-04-30 Sat 22:37 -->
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
<meta name="generator" content="Org-mode" />
|
||||
<style type="text/css">
|
||||
@@ -140,7 +139,7 @@ for the JavaScript code in this tag.
|
||||
<nav>
|
||||
<ul class="center">
|
||||
<li> <a href="index.html">Overview</a>
|
||||
<li> <a href="https://github.com/capitaomorte/yasnippet/blob/master/README.mdown">
|
||||
<li> <a href="https://github.com/joaotavora/yasnippet/blob/master/README.mdown">
|
||||
Intro and Tutorial</a>
|
||||
<li class="center">Snippet
|
||||
<ul>
|
||||
@@ -161,11 +160,10 @@ for the JavaScript code in this tag.
|
||||
<div id="text-table-of-contents">
|
||||
<ul>
|
||||
<li><a href="#sec-1">Why is there an extra newline?</a></li>
|
||||
<li><a href="#sec-2">Why doesn't TAB expand a snippet?</a></li>
|
||||
<li><a href="#sec-3">Why doesn't TAB navigation work with flyspell</a></li>
|
||||
<li><a href="#sec-4">How to I use alternative keys, i.e. not TAB?</a></li>
|
||||
<li><a href="#sec-5">How do I turn off the minor mode where in some buffers?</a></li>
|
||||
<li><a href="#sec-6">How do I define an abbrev key containing characters not supported by the filesystem?</a></li>
|
||||
<li><a href="#sec-2">Why doesn't TAB navigation work with flyspell</a></li>
|
||||
<li><a href="#sec-3">How to I use alternative keys, i.e. not TAB?</a></li>
|
||||
<li><a href="#sec-4">How do I turn off the minor mode where in some buffers?</a></li>
|
||||
<li><a href="#sec-5">How do I define an abbrev key containing characters not supported by the filesystem?</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@@ -174,120 +172,24 @@ for the JavaScript code in this tag.
|
||||
<h2 id="sec-1">Why is there an extra newline?</h2>
|
||||
<div class="outline-text-2" id="text-1">
|
||||
<p>
|
||||
If you have a newline at the end of the snippet definition file, then
|
||||
YASnippet will add a newline when you expanding a snippet. Please don't
|
||||
add a newline at the end if you don't want it when you saving the
|
||||
snippet file.
|
||||
If there is a newline at the end of a snippet definition file,
|
||||
YASnippet will add a newline when expanding that snippet. When editing
|
||||
or saving a snippet file, please be careful not to accidentally add a
|
||||
terminal newline.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Note some editors will automatically add a newline for you. In Emacs, if
|
||||
you set <code>require-final-newline</code> to <code>t</code>, it will add the final newline
|
||||
for you automatically.
|
||||
Note that some editors will automatically add a newline for you. In
|
||||
Emacs, if you set <code>require-final-newline</code> to <code>t</code>, it will add the
|
||||
final newline automatically.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-sec-2" class="outline-2">
|
||||
<h2 id="sec-2">Why doesn't TAB expand a snippet?</h2>
|
||||
<h2 id="sec-2">Why doesn't TAB navigation work with flyspell</h2>
|
||||
<div class="outline-text-2" id="text-2">
|
||||
<p>
|
||||
First check the mode line to see if there's <code>yas</code>. If not, then try
|
||||
<code>M-x yas-minor-mode</code> to manually turn on the minor mode and try to
|
||||
expand the snippet again. If it works, then, you can add the following
|
||||
code to your <code>.emacs</code> <i>before</i> loading YASnippet:
|
||||
</p>
|
||||
|
||||
<div class="org-src-container">
|
||||
|
||||
<pre class="src src-emacs-lisp">(add-hook 'the-major-mode-hook 'yas-minor-mode-on)
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
where <code>the-major-mode</code> is the major mode in which <a href="snippet-reference.html#yas-minor-mode"><code>yas-minor-mode</code></a> isn't
|
||||
enabled by default.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
From YASnippet 0.6 you can also use the command <code>M-x yas-global-mode</code> to
|
||||
turn on YASnippet automatically for <i>all</i> major modes.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
If <a href="snippet-reference.html#yas-minor-mode"><code>yas-minor-mode</code></a> is on but the snippet still not expanded. Then try
|
||||
to see what command is bound to the <code>TAB</code> key: press <code>C-h k</code> and then
|
||||
press <code>TAB</code>. Emacs will show you the result.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
You'll see a buffer prompted by Emacs saying that
|
||||
<code>TAB runs the command ...</code>. Alternatively, you might see
|
||||
<code><tab> runs the command ...</code>, note the difference between <code>TAB</code> and
|
||||
<code><tab></code> where the latter has priority. If you see <code><tab></code> bound to a
|
||||
command other than <a href="snippet-reference.html#yas-expand"><code>yas-expand</code></a>, (e.g. in <code>org-mode</code>) you can try the
|
||||
following code to work around:
|
||||
</p>
|
||||
|
||||
<div class="org-src-container">
|
||||
|
||||
<pre class="src src-emacs-lisp">(add-hook 'org-mode-hook
|
||||
(<span class="org-keyword">let</span> ((original-command (lookup-key org-mode-map [tab])))
|
||||
`(<span class="org-keyword">lambda</span> ()
|
||||
(setq yas-fallback-behavior
|
||||
'(apply ,original-command))
|
||||
(local-set-key [tab] 'yas-expand))))
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
replace <code>org-mode-hook</code> and <code>org-mode-map</code> with the major mode hook you
|
||||
are dealing with (Use <code>C-h m</code> to see what major mode you are in).
|
||||
</p>
|
||||
|
||||
<p>
|
||||
As an alternative, you can also try
|
||||
</p>
|
||||
|
||||
<div class="org-src-container">
|
||||
|
||||
<pre class="src src-emacs-lisp">(<span class="org-keyword">defun</span> <span class="org-function-name">yas-advise-indent-function</span> (function-symbol)
|
||||
(eval `(<span class="org-keyword">defadvice</span> ,function-symbol (around yas-try-expand-first activate)
|
||||
,(format
|
||||
<span class="org-string">"Try to expand a snippet before point, then call `</span><span class="org-string"><span class="org-constant">%s</span></span><span class="org-string">' as usual"</span>
|
||||
function-symbol)
|
||||
(<span class="org-keyword">let</span> ((yas-fallback-behavior nil))
|
||||
(<span class="org-keyword">unless</span> (and (interactive-p)
|
||||
(yas-expand))
|
||||
ad-do-it)))))
|
||||
|
||||
(yas-advise-indent-function 'ruby-indent-line)
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
To <i>advise</i> the modes indentation function bound to TAB, (in this case
|
||||
<code>ruby-indent-line</code>) to first try to run <a href="snippet-reference.html#yas-expand"><code>yas-expand</code></a>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
If the output of <code>C-h k RET <tab></code> tells you that <code><tab></code> is indeed
|
||||
bound to <a href="snippet-reference.html#yas-expand"><code>yas-expand</code></a> but YASnippet still doesn't work, check your
|
||||
configuration and you may also ask for help on the <a href="http://groups.google.com/group/smart-snippet">discussion group</a>.
|
||||
See this particular <a href="http://code.google.com/p/yasnippet/issues/detail?id=93&can=1">thread</a> for quite some solutions and alternatives.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Don't forget to attach the information on what command is bound to TAB
|
||||
as well as the mode information (Can be obtained by <code>C-h m</code>).
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-sec-3" class="outline-2">
|
||||
<h2 id="sec-3">Why doesn't TAB navigation work with flyspell</h2>
|
||||
<div class="outline-text-2" id="text-3">
|
||||
<p>
|
||||
A workaround is to inhibit flyspell overlays while the snippet is
|
||||
active:
|
||||
</p>
|
||||
@@ -295,8 +197,8 @@ active:
|
||||
<div class="org-src-container">
|
||||
|
||||
<pre class="src src-emacs-lisp">(add-hook 'flyspell-incorrect-hook
|
||||
#'(<span class="org-keyword">lambda</span> (dummy1 dummy2 dymmy3)
|
||||
(and yas-active-field-overlay
|
||||
#'(lambda (dummy1 dummy2 dymmy3)
|
||||
(<span class="org-keyword">and</span> yas-active-field-overlay
|
||||
(overlay-buffer yas-active-field-overlay))))
|
||||
</pre>
|
||||
</div>
|
||||
@@ -312,9 +214,9 @@ solve this problem, drop a line in the
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-sec-4" class="outline-2">
|
||||
<h2 id="sec-4">How to I use alternative keys, i.e. not TAB?</h2>
|
||||
<div class="outline-text-2" id="text-4">
|
||||
<div id="outline-container-sec-3" class="outline-2">
|
||||
<h2 id="sec-3">How to I use alternative keys, i.e. not TAB?</h2>
|
||||
<div class="outline-text-2" id="text-3">
|
||||
<p>
|
||||
Edit the keymaps <a href="snippet-reference.html#yas-minor-mode-map"><code>yas-minor-mode-map</code></a> and
|
||||
<a href="snippet-reference.html#yas-keymap"><code>yas-keymap</code></a> as you would any other keymap:
|
||||
@@ -324,7 +226,7 @@ Edit the keymaps <a href="snippet-reference.html#yas-minor-mode-map"><code>yas-m
|
||||
|
||||
<pre class="src src-emacs-lisp">(define-key yas-minor-mode-map (kbd <span class="org-string">"<tab>"</span>) nil)
|
||||
(define-key yas-minor-mode-map (kbd <span class="org-string">"TAB"</span>) nil)
|
||||
(define-key yas-minor-mode-map (kbd <span class="org-string">"<the new key>"</span>) 'yas-expand)
|
||||
(define-key yas-minor-mode-map (kbd <span class="org-string">"<the new key>"</span>) yas-maybe-expand)
|
||||
|
||||
<span class="org-comment-delimiter">;;</span><span class="org-comment">keys for navigation</span>
|
||||
(define-key yas-keymap [(tab)] nil)
|
||||
@@ -338,9 +240,9 @@ Edit the keymaps <a href="snippet-reference.html#yas-minor-mode-map"><code>yas-m
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-sec-5" class="outline-2">
|
||||
<h2 id="sec-5">How do I turn off the minor mode where in some buffers?</h2>
|
||||
<div class="outline-text-2" id="text-5">
|
||||
<div id="outline-container-sec-4" class="outline-2">
|
||||
<h2 id="sec-4">How do I turn off the minor mode where in some buffers?</h2>
|
||||
<div class="outline-text-2" id="text-4">
|
||||
<p>
|
||||
The best way, since version 0.6.1c, is to set the default value of the
|
||||
variable <a href="snippet-reference.html#yas-dont-activate"><code>yas-dont-activate</code></a> to a lambda function like so:
|
||||
@@ -349,8 +251,8 @@ variable <a href="snippet-reference.html#yas-dont-activate"><code>yas-dont-activ
|
||||
<div class="org-src-container">
|
||||
|
||||
<pre class="src src-emacs-lisp">(set-default 'yas-dont-activate
|
||||
#'(<span class="org-keyword">lambda</span> ()
|
||||
(and yas-root-directory
|
||||
#'(lambda ()
|
||||
(<span class="org-keyword">and</span> yas-root-directory
|
||||
(null (yas-get-snippet-tables)))))
|
||||
</pre>
|
||||
</div>
|
||||
@@ -363,9 +265,9 @@ but only once you have setup your yas-root-directory.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-sec-6" class="outline-2">
|
||||
<h2 id="sec-6">How do I define an abbrev key containing characters not supported by the filesystem?</h2>
|
||||
<div class="outline-text-2" id="text-6">
|
||||
<div id="outline-container-sec-5" class="outline-2">
|
||||
<h2 id="sec-5">How do I define an abbrev key containing characters not supported by the filesystem?</h2>
|
||||
<div class="outline-text-2" id="text-5">
|
||||
<ul class="org-ul">
|
||||
<li><b>Note</b>: This question applies if you're still defining snippets
|
||||
whose key <i>is</i> the filename. This is behavior still provided by
|
||||
@@ -399,8 +301,7 @@ directive:
|
||||
</div>
|
||||
</div>
|
||||
<div id="postamble" class="status">
|
||||
<hr><p class='creator'>Generated by <a href="http://www.gnu.org/software/emacs/">Emacs</a> 24.5.1 (<a href="http://orgmode.org">Org</a> mode 8.2.10) on from df229b9ab8db87fe5a1133365fdc299a65f9be86
|
||||
</p>
|
||||
<hr><p class='creator'>Generated by <a href="http://www.gnu.org/software/emacs/">Emacs</a> 25.2.50.5 (<a href="http://orgmode.org">Org</a> mode 8.2.10) from 0.12.2 (2017-08-29 02:08:58)</p>
|
||||
<p class='xhtml-validation'><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user