Automatic documentation update.

From 7703a55ac416a131dec45fa6a1e0ec1e31adf760
This commit is contained in:
Noam Postavsky 2015-09-24 21:18:15 -04:00
parent b925a0388f
commit 1167e57937
7 changed files with 1474 additions and 1508 deletions

181
faq.html
View File

@ -1,39 +1,61 @@
<?xml version="1.0" encoding="iso-8859-1"?> <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head> <head>
<title>Frequently Asked Questions</title> <title>Frequently Asked Questions</title>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"/> <!-- 2015-09-24 Thu 21:15 -->
<meta name="title" content="Frequently Asked Questions"/> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="generator" content="Org-mode" /> <meta name="generator" content="Org-mode" />
<meta name="generated" content="2014-10-01T21:16+0100"/>
<meta name="author" content=""/>
<meta name="description" content=""/>
<meta name="keywords" content=""/>
<style type="text/css"> <style type="text/css">
<!--/*--><![CDATA[/*><!--*/ <!--/*--><![CDATA[/*><!--*/
html { font-family: Times, serif; font-size: 12pt; }
.title { text-align: center; } .title { text-align: center; }
.todo { color: red; } .todo { font-family: monospace; color: red; }
.done { color: green; } .done { color: green; }
.tag { background-color: #add8e6; font-weight:normal } .tag { background-color: #eee; font-family: monospace;
.target { } padding: 2px; font-size: 80%; font-weight: normal; }
.timestamp { color: #bebebe; } .timestamp { color: #bebebe; }
.timestamp-kwd { color: #5f9ea0; } .timestamp-kwd { color: #5f9ea0; }
.right { margin-left: auto; margin-right: 0px; text-align: right; } .right { margin-left: auto; margin-right: 0px; text-align: right; }
.left { margin-left: 0px; margin-right: auto; text-align: left; } .left { margin-left: 0px; margin-right: auto; text-align: left; }
.center { margin-left: auto; margin-right: auto; text-align: center; } .center { margin-left: auto; margin-right: auto; text-align: center; }
p.verse { margin-left: 3% } .underline { text-decoration: underline; }
#postamble p, #preamble p { font-size: 90%; margin: .2em; }
p.verse { margin-left: 3%; }
pre { pre {
border: 1pt solid #AEBDCC; border: 1px solid #ccc;
background-color: #F3F5F7; box-shadow: 3px 3px 3px #eee;
padding: 5pt; padding: 8pt;
font-family: courier, monospace; font-family: monospace;
font-size: 90%;
overflow: auto; overflow: auto;
margin: 1.2em;
} }
pre.src {
position: relative;
overflow: visible;
padding-top: 1.2em;
}
pre.src:before {
display: none;
position: absolute;
background-color: white;
top: -10px;
right: 10px;
padding: 3px;
border: 1px solid black;
}
pre.src:hover:before { display: inline;}
pre.src-sh:before { content: 'sh'; }
pre.src-bash:before { content: 'sh'; }
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
pre.src-R:before { content: 'R'; }
pre.src-perl:before { content: 'Perl'; }
pre.src-java:before { content: 'Java'; }
pre.src-sql:before { content: 'SQL'; }
table { border-collapse:collapse; } table { border-collapse:collapse; }
caption.t-above { caption-side: top; }
caption.t-bottom { caption-side: bottom; }
td, th { vertical-align:top; } td, th { vertical-align:top; }
th.right { text-align: center; } th.right { text-align: center; }
th.left { text-align: center; } th.left { text-align: center; }
@ -42,22 +64,27 @@
td.left { text-align: left; } td.left { text-align: left; }
td.center { text-align: center; } td.center { text-align: center; }
dt { font-weight: bold; } dt { font-weight: bold; }
div.figure { padding: 0.5em; } .footpara:nth-child(2) { display: inline; }
div.figure p { text-align: center; } .footpara { display: block; }
div.inlinetask { .footdef { margin-bottom: 1em; }
.figure { padding: 1em; }
.figure p { text-align: center; }
.inlinetask {
padding: 10px; padding: 10px;
border: 2px solid gray; border: 2px solid gray;
margin: 10px; margin: 10px;
background: #ffffcc; background: #ffffcc;
} }
#org-div-home-and-up
{ text-align: right; font-size: 70%; white-space: nowrap; }
textarea { overflow-x: auto; } textarea { overflow-x: auto; }
.linenr { font-size: smaller } .linenr { font-size: smaller }
.code-highlighted { background-color: #ffff00; } .code-highlighted { background-color: #ffff00; }
.org-info-js_info-navigation { border-style: none; } .org-info-js_info-navigation { border-style: none; }
#org-info-js_console-label { font-size:10px; font-weight:bold; #org-info-js_console-label
white-space:nowrap; } { font-size: 10px; font-weight: bold; white-space: nowrap; }
.org-info-js_search-highlight {background-color:#ffff00; color:#000000; .org-info-js_search-highlight
font-weight:bold; } { background-color: #ffff00; color: #000000; font-weight: bold; }
/*]]>*/--> /*]]>*/-->
</style> </style>
<link rel="stylesheet" type="text/css" href="stylesheets/manual.css" /> <link rel="stylesheet" type="text/css" href="stylesheets/manual.css" />
@ -107,11 +134,9 @@ for the JavaScript code in this tag.
} }
/*]]>*///--> /*]]>*///-->
</script> </script>
</head> </head>
<body> <body>
<div id="preamble" class="status">
<div id="preamble">
<nav> <nav>
<ul class="center"> <ul class="center">
<li> <a href="index.html">Overview</a> <li> <a href="index.html">Overview</a>
@ -128,14 +153,9 @@ for the JavaScript code in this tag.
<li> <a href="snippet-reference.html">Reference</a> <li> <a href="snippet-reference.html">Reference</a>
</ul> </ul>
</nav> </nav>
</div> </div>
<div id="content"> <div id="content">
<h1 class="title">Frequently Asked Questions</h1> <h1 class="title">Frequently Asked Questions</h1>
<div id="table-of-contents"> <div id="table-of-contents">
<h2>Table of Contents</h2> <h2>Table of Contents</h2>
<div id="text-table-of-contents"> <div id="text-table-of-contents">
@ -150,31 +170,27 @@ for the JavaScript code in this tag.
</div> </div>
</div> </div>
<div id="outline-container-1" class="outline-2"> <div id="outline-container-sec-1" class="outline-2">
<h2 id="sec-1">Why is there an extra newline?</h2> <h2 id="sec-1">Why is there an extra newline?</h2>
<div class="outline-text-2" id="text-1"> <div class="outline-text-2" id="text-1">
<p> <p>
If you have a newline at the end of the snippet definition file, then 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 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 add a newline at the end if you don't want it when you saving the
snippet file. snippet file.
</p> </p>
<p> <p>
Note some editors will automatically add a newline for you. In Emacs, if 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 you set <code>require-final-newline</code> to <code>t</code>, it will add the final newline
for you automatically. for you automatically.
</p> </p>
</div> </div>
</div> </div>
<div id="outline-container-2" class="outline-2"> <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 expand a snippet?</h2>
<div class="outline-text-2" id="text-2"> <div class="outline-text-2" id="text-2">
<p> <p>
First check the mode line to see if there's <code>yas</code>. If not, then try 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 <code>M-x yas-minor-mode</code> to manually turn on the minor mode and try to
@ -182,25 +198,28 @@ expand the snippet again. If it works, then, you can add the following
code to your <code>.emacs</code> <i>before</i> loading YASnippet: code to your <code>.emacs</code> <i>before</i> loading YASnippet:
</p> </p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(add-hook 'the-major-mode-hook 'yas-minor-mode-on)
<pre class="example">(add-hook 'the-major-mode-hook 'yas-minor-mode-on)
</pre> </pre>
</div>
<p> <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 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. enabled by default.
</p> </p>
<p> <p>
From YASnippet 0.6 you can also use the command <code>M-x yas-global-mode</code> to 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. turn on YASnippet automatically for <i>all</i> major modes.
</p> </p>
<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 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 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. press <code>TAB</code>. Emacs will show you the result.
</p> </p>
<p> <p>
You'll see a buffer prompted by Emacs saying that 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>. Alternatively, you might see
@ -210,28 +229,29 @@ command other than <a href="snippet-reference.html#yas-expand"><code>yas-expand<
following code to work around: following code to work around:
</p> </p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(add-hook 'org-mode-hook
<pre class="example">(add-hook 'org-mode-hook
(let ((original-command (lookup-key org-mode-map [tab]))) (let ((original-command (lookup-key org-mode-map [tab])))
`(lambda () `(lambda ()
(setq yas-fallback-behavior (setq yas-fallback-behavior
'(apply ,original-command)) '(apply ,original-command))
(local-set-key [tab] 'yas-expand)))) (local-set-key [tab] 'yas-expand))))
</pre> </pre>
</div>
<p> <p>
replace <code>org-mode-hook</code> and <code>org-mode-map</code> with the major mode hook you 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). are dealing with (Use <code>C-h m</code> to see what major mode you are in).
</p> </p>
<p> <p>
As an alternative, you can also try As an alternative, you can also try
</p> </p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(defun yas-advise-indent-function (function-symbol)
<pre class="example">(defun yas-advise-indent-function (function-symbol)
(eval `(defadvice ,function-symbol (around yas-try-expand-first activate) (eval `(defadvice ,function-symbol (around yas-try-expand-first activate)
,(format ,(format
"Try to expand a snippet before point, then call `%s' as usual" "Try to expand a snippet before point, then call `%s' as usual"
@ -243,44 +263,43 @@ As an alternative, you can also try
(yas-advise-indent-function 'ruby-indent-line) (yas-advise-indent-function 'ruby-indent-line)
</pre> </pre>
</div>
<p> <p>
To <i>advise</i> the modes indentation function bound to TAB, (in this case 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>. <code>ruby-indent-line</code>) to first try to run <a href="snippet-reference.html#yas-expand"><code>yas-expand</code></a>.
</p> </p>
<p> <p>
If the output of <code>C-h k RET &lt;tab&gt;</code> tells you that <code>&lt;tab&gt;</code> is indeed If the output of <code>C-h k RET &lt;tab&gt;</code> tells you that <code>&lt;tab&gt;</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 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>. 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&amp;can=1">thread</a> for quite some solutions and alternatives. 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>
<p> <p>
Don't forget to attach the information on what command is bound to TAB 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>). as well as the mode information (Can be obtained by <code>C-h m</code>).
</p> </p>
</div> </div>
</div> </div>
<div id="outline-container-3" class="outline-2"> <div id="outline-container-sec-3" class="outline-2">
<h2 id="sec-3">Why doesn't TAB navigation work with flyspell</h2> <h2 id="sec-3">Why doesn't TAB navigation work with flyspell</h2>
<div class="outline-text-2" id="text-3"> <div class="outline-text-2" id="text-3">
<p> <p>
A workaround is to inhibit flyspell overlays while the snippet is A workaround is to inhibit flyspell overlays while the snippet is
active: active:
</p> </p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(add-hook 'flyspell-incorrect-hook
<pre class="example">(add-hook 'flyspell-incorrect-hook
#'(lambda (dummy1 dummy2 dymmy3) #'(lambda (dummy1 dummy2 dymmy3)
(and yas-active-field-overlay (and yas-active-field-overlay
(overlay-buffer yas-active-field-overlay)))) (overlay-buffer yas-active-field-overlay))))
</pre> </pre>
</div>
<p> <p>
This is apparently related to overlay priorities. For some reason, the This is apparently related to overlay priorities. For some reason, the
@ -291,22 +310,19 @@ solve this problem, drop a line in the
<a href="http://groups.google.com/group/smart-snippet">discussion group</a>. <a href="http://groups.google.com/group/smart-snippet">discussion group</a>.
</p> </p>
</div> </div>
</div> </div>
<div id="outline-container-4" class="outline-2"> <div id="outline-container-sec-4" class="outline-2">
<h2 id="sec-4">How to I use alternative keys, i.e. not TAB?</h2> <h2 id="sec-4">How to I use alternative keys, i.e. not TAB?</h2>
<div class="outline-text-2" id="text-4"> <div class="outline-text-2" id="text-4">
<p> <p>
Edit the keymaps <a href="snippet-reference.html#yas-minor-mode-map"><code>yas-minor-mode-map</code></a> and 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: <a href="snippet-reference.html#yas-keymap"><code>yas-keymap</code></a> as you would any other keymap:
</p> </p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(define-key yas-minor-mode-map (kbd "&lt;tab&gt;") nil)
<pre class="example">(define-key yas-minor-mode-map (kbd "&lt;tab&gt;") nil)
(define-key yas-minor-mode-map (kbd "TAB") nil) (define-key yas-minor-mode-map (kbd "TAB") nil)
(define-key yas-minor-mode-map (kbd "&lt;the new key&gt;") 'yas-expand) (define-key yas-minor-mode-map (kbd "&lt;the new key&gt;") 'yas-expand)
@ -318,30 +334,26 @@ Edit the keymaps <a href="snippet-reference.html#yas-minor-mode-map"><code>yas-m
(define-key yas-keymap (kbd "&lt;new-next-field-key&gt;") 'yas-next-field-or-maybe-expand) (define-key yas-keymap (kbd "&lt;new-next-field-key&gt;") 'yas-next-field-or-maybe-expand)
(define-key yas-keymap (kbd "&lt;new-prev-field-key&gt;") 'yas-prev) (define-key yas-keymap (kbd "&lt;new-prev-field-key&gt;") 'yas-prev)
</pre> </pre>
</div>
</div>
</div> </div>
</div> <div id="outline-container-sec-5" class="outline-2">
<div id="outline-container-5" class="outline-2">
<h2 id="sec-5">How do I turn off the minor mode where in some buffers?</h2> <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 class="outline-text-2" id="text-5">
<p> <p>
The best way, since version 0.6.1c, is to set the default value of the 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: variable <a href="snippet-reference.html#yas-dont-activate"><code>yas-dont-activate</code></a> to a lambda function like so:
</p> </p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(set-default 'yas-dont-activate
<pre class="example">(set-default 'yas-dont-activate
#'(lambda () #'(lambda ()
(and yas-root-directory (and yas-root-directory
(null (yas-get-snippet-tables))))) (null (yas-get-snippet-tables)))))
</pre> </pre>
</div>
<p> <p>
This is also the default value starting for that version. It skips the This is also the default value starting for that version. It skips the
@ -349,28 +361,25 @@ minor mode in buffers where it is not applicable (no snippet tables),
but only once you have setup your yas-root-directory. but only once you have setup your yas-root-directory.
</p> </p>
</div> </div>
</div> </div>
<div id="outline-container-6" class="outline-2"> <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> <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 class="outline-text-2" id="text-6">
<ul class="org-ul">
<ul>
<li><b>Note</b>: This question applies if you're still defining snippets <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 whose key <i>is</i> the filename. This is behavior still provided by
version 0.6 for backward compatibilty, but is somewhat version 0.6 for backward compatibilty, but is somewhat
deprecated&hellip; deprecated&#x2026;
</li> </li>
</ul> </ul>
<p> <p>
For example, you want to define a snippet by the key <code>&lt;</code> which is not a For example, you want to define a snippet by the key <code>&lt;</code> which is not a
valid character for filename on Windows. This means you can't use the valid character for filename on Windows. This means you can't use the
filename as a trigger key in this case. filename as a trigger key in this case.
</p> </p>
<p> <p>
You should rather use the <code># key:</code> directive to specify the key of the You should rather use the <code># key:</code> directive to specify the key of the
defined snippet explicitly and name your snippet with an arbitrary valid defined snippet explicitly and name your snippet with an arbitrary valid
@ -378,23 +387,21 @@ filename, <code>lt.YASnippet</code> for example, using <code>&lt;</code> for the
directive: directive:
</p> </p>
<div class="org-src-container">
<pre class="src src-snippet"># key: &lt;
<pre class="example"># key: &lt;
# name: &lt;...&gt;&lt;/...&gt; # name: &lt;...&gt;&lt;/...&gt;
# -- # --
&lt;${1:div}&gt;$0&lt;/$1&gt; &lt;${1:div}&gt;$0&lt;/$1&gt;
</pre> </pre>
</div> </div>
</div> </div>
</div> </div>
</div>
<div id="postamble"> <div id="postamble" class="status">
<hr><p class='creator'>Generated by <a href="http://orgmode.org">Org</a> version 7.9.3f with <a href="http://www.gnu.org/software/emacs/">Emacs</a> version 24 on 2014-10-01T21:16+0100 from 08b044e559cc350c6e7142d088ec2d4a82e378cb <hr><p class='creator'>Generated by <a href="http://www.gnu.org/software/emacs/">Emacs</a> 24.4.91.1 (<a href="http://orgmode.org">Org</a> mode 8.2.10) on from 7703a55ac416a131dec45fa6a1e0ec1e31adf760
</p> </p>
<p class='xhtml-validation'><a href="http://validator.w3.org/check?uri=referer">Validate XHTML 1.0</a></p> <p class='xhtml-validation'><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
</div> </div>
</body> </body>
</html> </html>

View File

@ -4,36 +4,58 @@
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head> <head>
<title>Yet another snippet extension</title> <title>Yet another snippet extension</title>
<!-- 2015-09-24 Thu 21:15 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="title" content="Yet another snippet extension"/>
<meta name="generator" content="Org-mode" /> <meta name="generator" content="Org-mode" />
<meta name="generated" content="2014-10-01T21:16+0100"/>
<meta name="author" content=""/>
<meta name="description" content=""/>
<meta name="keywords" content=""/>
<style type="text/css"> <style type="text/css">
<!--/*--><![CDATA[/*><!--*/ <!--/*--><![CDATA[/*><!--*/
html { font-family: Times, serif; font-size: 12pt; }
.title { text-align: center; } .title { text-align: center; }
.todo { color: red; } .todo { font-family: monospace; color: red; }
.done { color: green; } .done { color: green; }
.tag { background-color: #add8e6; font-weight:normal } .tag { background-color: #eee; font-family: monospace;
.target { } padding: 2px; font-size: 80%; font-weight: normal; }
.timestamp { color: #bebebe; } .timestamp { color: #bebebe; }
.timestamp-kwd { color: #5f9ea0; } .timestamp-kwd { color: #5f9ea0; }
.right { margin-left: auto; margin-right: 0px; text-align: right; } .right { margin-left: auto; margin-right: 0px; text-align: right; }
.left { margin-left: 0px; margin-right: auto; text-align: left; } .left { margin-left: 0px; margin-right: auto; text-align: left; }
.center { margin-left: auto; margin-right: auto; text-align: center; } .center { margin-left: auto; margin-right: auto; text-align: center; }
p.verse { margin-left: 3% } .underline { text-decoration: underline; }
#postamble p, #preamble p { font-size: 90%; margin: .2em; }
p.verse { margin-left: 3%; }
pre { pre {
border: 1pt solid #AEBDCC; border: 1px solid #ccc;
background-color: #F3F5F7; box-shadow: 3px 3px 3px #eee;
padding: 5pt; padding: 8pt;
font-family: courier, monospace; font-family: monospace;
font-size: 90%;
overflow: auto; overflow: auto;
margin: 1.2em;
} }
pre.src {
position: relative;
overflow: visible;
padding-top: 1.2em;
}
pre.src:before {
display: none;
position: absolute;
background-color: white;
top: -10px;
right: 10px;
padding: 3px;
border: 1px solid black;
}
pre.src:hover:before { display: inline;}
pre.src-sh:before { content: 'sh'; }
pre.src-bash:before { content: 'sh'; }
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
pre.src-R:before { content: 'R'; }
pre.src-perl:before { content: 'Perl'; }
pre.src-java:before { content: 'Java'; }
pre.src-sql:before { content: 'SQL'; }
table { border-collapse:collapse; } table { border-collapse:collapse; }
caption.t-above { caption-side: top; }
caption.t-bottom { caption-side: bottom; }
td, th { vertical-align:top; } td, th { vertical-align:top; }
th.right { text-align: center; } th.right { text-align: center; }
th.left { text-align: center; } th.left { text-align: center; }
@ -42,22 +64,27 @@
td.left { text-align: left; } td.left { text-align: left; }
td.center { text-align: center; } td.center { text-align: center; }
dt { font-weight: bold; } dt { font-weight: bold; }
div.figure { padding: 0.5em; } .footpara:nth-child(2) { display: inline; }
div.figure p { text-align: center; } .footpara { display: block; }
div.inlinetask { .footdef { margin-bottom: 1em; }
.figure { padding: 1em; }
.figure p { text-align: center; }
.inlinetask {
padding: 10px; padding: 10px;
border: 2px solid gray; border: 2px solid gray;
margin: 10px; margin: 10px;
background: #ffffcc; background: #ffffcc;
} }
#org-div-home-and-up
{ text-align: right; font-size: 70%; white-space: nowrap; }
textarea { overflow-x: auto; } textarea { overflow-x: auto; }
.linenr { font-size: smaller } .linenr { font-size: smaller }
.code-highlighted { background-color: #ffff00; } .code-highlighted { background-color: #ffff00; }
.org-info-js_info-navigation { border-style: none; } .org-info-js_info-navigation { border-style: none; }
#org-info-js_console-label { font-size:10px; font-weight:bold; #org-info-js_console-label
white-space:nowrap; } { font-size: 10px; font-weight: bold; white-space: nowrap; }
.org-info-js_search-highlight {background-color:#ffff00; color:#000000; .org-info-js_search-highlight
font-weight:bold; } { background-color: #ffff00; color: #000000; font-weight: bold; }
/*]]>*/--> /*]]>*/-->
</style> </style>
<link rel="stylesheet" type="text/css" href="stylesheets/manual.css" /> <link rel="stylesheet" type="text/css" href="stylesheets/manual.css" />
@ -107,11 +134,9 @@ for the JavaScript code in this tag.
} }
/*]]>*///--> /*]]>*///-->
</script> </script>
</head> </head>
<body> <body>
<div id="preamble" class="status">
<div id="preamble">
<nav> <nav>
<ul class="center"> <ul class="center">
<li> <a href="index.html">Overview</a> <li> <a href="index.html">Overview</a>
@ -128,15 +153,14 @@ for the JavaScript code in this tag.
<li> <a href="snippet-reference.html">Reference</a> <li> <a href="snippet-reference.html">Reference</a>
</ul> </ul>
</nav> </nav>
</div> </div>
<div id="content"> <div id="content">
<h1 class="title">Yet another snippet extension</h1> <h1 class="title">Yet another snippet extension</h1>
<p>
<p>The YASnippet documentation has been split into separate parts: The YASnippet documentation has been split into separate parts:
</p> </p>
<ol>
<ol class="org-ol">
<li><a href="https://github.com/capitaomorte/yasnippet/blob/master/README.mdown">README</a> <li><a href="https://github.com/capitaomorte/yasnippet/blob/master/README.mdown">README</a>
<p> <p>
@ -144,22 +168,26 @@ for the JavaScript code in this tag.
notes. notes.
</p> </p>
</li> </li>
<li><a href="snippet-organization.html">Organizing Snippets</a> <li><a href="snippet-organization.html">Organizing Snippets</a>
<p> <p>
Describes ways to organize your snippets in the hard disk. Describes ways to organize your snippets in the hard disk.
</p> </p>
</li> </li>
<li><a href="snippet-expansion.html">Expanding Snippets</a> <li><a href="snippet-expansion.html">Expanding Snippets</a>
<p> <p>
Describes how YASnippet chooses snippets for expansion at point. Describes how YASnippet chooses snippets for expansion at point.
</p> </p>
<p> <p>
Maybe, you'll want some snippets to be expanded in a particular mode, Maybe, you'll want some snippets to be expanded in a particular mode,
or only under certain conditions, or be prompted using <code>ido</code>, etc&hellip; or only under certain conditions, or be prompted using <code>ido</code>, etc&#x2026;
</p> </p>
</li> </li>
<li><a href="snippet-development.html">Writing Snippets</a> <li><a href="snippet-development.html">Writing Snippets</a>
<p> <p>
@ -168,6 +196,7 @@ for the JavaScript code in this tag.
TextMate snippets. TextMate snippets.
</p> </p>
</li> </li>
<li><a href="snippet-menu.html">The YASnippet menu</a> <li><a href="snippet-menu.html">The YASnippet menu</a>
<p> <p>
@ -175,29 +204,27 @@ for the JavaScript code in this tag.
snippets. snippets.
</p> </p>
</li> </li>
<li><a href="faq.html">Frequently asked questions</a> <li><a href="faq.html">Frequently asked questions</a>
<p> <p>
Answers to frequently asked questions. Answers to frequently asked questions.
</p> </p>
</li> </li>
<li><a href="snippet-reference.html">YASnippet Symbol Reference</a> <li><a href="snippet-reference.html">YASnippet Symbol Reference</a>
<p> <p>
An automatically generated listing of all YASnippet commands, An automatically generated listing of all YASnippet commands,
(customization) variables, and functions. (customization) variables, and functions.
</p></li>
</ol>
</div>
<div id="postamble">
<hr><p class='creator'>Generated by <a href="http://orgmode.org">Org</a> version 7.9.3f with <a href="http://www.gnu.org/software/emacs/">Emacs</a> version 24 on 2014-10-01T21:16+0100 from 08b044e559cc350c6e7142d088ec2d4a82e378cb
</p> </p>
<p class='xhtml-validation'><a href="http://validator.w3.org/check?uri=referer">Validate XHTML 1.0</a></p> </li>
</ol>
</div>
<div id="postamble" class="status">
<hr><p class='creator'>Generated by <a href="http://www.gnu.org/software/emacs/">Emacs</a> 24.4.91.1 (<a href="http://orgmode.org">Org</a> mode 8.2.10) on from 7703a55ac416a131dec45fa6a1e0ec1e31adf760
</p>
<p class='xhtml-validation'><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
</div> </div>
</body> </body>
</html> </html>

View File

@ -1,39 +1,61 @@
<?xml version="1.0" encoding="iso-8859-1"?> <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head> <head>
<title>Writing snippets</title> <title>Writing snippets</title>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"/> <!-- 2015-09-24 Thu 21:15 -->
<meta name="title" content="Writing snippets"/> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="generator" content="Org-mode" /> <meta name="generator" content="Org-mode" />
<meta name="generated" content="2014-10-01T21:16+0100"/>
<meta name="author" content=""/>
<meta name="description" content=""/>
<meta name="keywords" content=""/>
<style type="text/css"> <style type="text/css">
<!--/*--><![CDATA[/*><!--*/ <!--/*--><![CDATA[/*><!--*/
html { font-family: Times, serif; font-size: 12pt; }
.title { text-align: center; } .title { text-align: center; }
.todo { color: red; } .todo { font-family: monospace; color: red; }
.done { color: green; } .done { color: green; }
.tag { background-color: #add8e6; font-weight:normal } .tag { background-color: #eee; font-family: monospace;
.target { } padding: 2px; font-size: 80%; font-weight: normal; }
.timestamp { color: #bebebe; } .timestamp { color: #bebebe; }
.timestamp-kwd { color: #5f9ea0; } .timestamp-kwd { color: #5f9ea0; }
.right { margin-left: auto; margin-right: 0px; text-align: right; } .right { margin-left: auto; margin-right: 0px; text-align: right; }
.left { margin-left: 0px; margin-right: auto; text-align: left; } .left { margin-left: 0px; margin-right: auto; text-align: left; }
.center { margin-left: auto; margin-right: auto; text-align: center; } .center { margin-left: auto; margin-right: auto; text-align: center; }
p.verse { margin-left: 3% } .underline { text-decoration: underline; }
#postamble p, #preamble p { font-size: 90%; margin: .2em; }
p.verse { margin-left: 3%; }
pre { pre {
border: 1pt solid #AEBDCC; border: 1px solid #ccc;
background-color: #F3F5F7; box-shadow: 3px 3px 3px #eee;
padding: 5pt; padding: 8pt;
font-family: courier, monospace; font-family: monospace;
font-size: 90%;
overflow: auto; overflow: auto;
margin: 1.2em;
} }
pre.src {
position: relative;
overflow: visible;
padding-top: 1.2em;
}
pre.src:before {
display: none;
position: absolute;
background-color: white;
top: -10px;
right: 10px;
padding: 3px;
border: 1px solid black;
}
pre.src:hover:before { display: inline;}
pre.src-sh:before { content: 'sh'; }
pre.src-bash:before { content: 'sh'; }
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
pre.src-R:before { content: 'R'; }
pre.src-perl:before { content: 'Perl'; }
pre.src-java:before { content: 'Java'; }
pre.src-sql:before { content: 'SQL'; }
table { border-collapse:collapse; } table { border-collapse:collapse; }
caption.t-above { caption-side: top; }
caption.t-bottom { caption-side: bottom; }
td, th { vertical-align:top; } td, th { vertical-align:top; }
th.right { text-align: center; } th.right { text-align: center; }
th.left { text-align: center; } th.left { text-align: center; }
@ -42,22 +64,27 @@
td.left { text-align: left; } td.left { text-align: left; }
td.center { text-align: center; } td.center { text-align: center; }
dt { font-weight: bold; } dt { font-weight: bold; }
div.figure { padding: 0.5em; } .footpara:nth-child(2) { display: inline; }
div.figure p { text-align: center; } .footpara { display: block; }
div.inlinetask { .footdef { margin-bottom: 1em; }
.figure { padding: 1em; }
.figure p { text-align: center; }
.inlinetask {
padding: 10px; padding: 10px;
border: 2px solid gray; border: 2px solid gray;
margin: 10px; margin: 10px;
background: #ffffcc; background: #ffffcc;
} }
#org-div-home-and-up
{ text-align: right; font-size: 70%; white-space: nowrap; }
textarea { overflow-x: auto; } textarea { overflow-x: auto; }
.linenr { font-size: smaller } .linenr { font-size: smaller }
.code-highlighted { background-color: #ffff00; } .code-highlighted { background-color: #ffff00; }
.org-info-js_info-navigation { border-style: none; } .org-info-js_info-navigation { border-style: none; }
#org-info-js_console-label { font-size:10px; font-weight:bold; #org-info-js_console-label
white-space:nowrap; } { font-size: 10px; font-weight: bold; white-space: nowrap; }
.org-info-js_search-highlight {background-color:#ffff00; color:#000000; .org-info-js_search-highlight
font-weight:bold; } { background-color: #ffff00; color: #000000; font-weight: bold; }
/*]]>*/--> /*]]>*/-->
</style> </style>
<link rel="stylesheet" type="text/css" href="stylesheets/manual.css" /> <link rel="stylesheet" type="text/css" href="stylesheets/manual.css" />
@ -107,11 +134,9 @@ for the JavaScript code in this tag.
} }
/*]]>*///--> /*]]>*///-->
</script> </script>
</head> </head>
<body> <body>
<div id="preamble" class="status">
<div id="preamble">
<nav> <nav>
<ul class="center"> <ul class="center">
<li> <a href="index.html">Overview</a> <li> <a href="index.html">Overview</a>
@ -128,14 +153,9 @@ for the JavaScript code in this tag.
<li> <a href="snippet-reference.html">Reference</a> <li> <a href="snippet-reference.html">Reference</a>
</ul> </ul>
</nav> </nav>
</div> </div>
<div id="content"> <div id="content">
<h1 class="title">Writing snippets</h1> <h1 class="title">Writing snippets</h1>
<div id="table-of-contents"> <div id="table-of-contents">
<h2>Table of Contents</h2> <h2>Table of Contents</h2>
<div id="text-table-of-contents"> <div id="text-table-of-contents">
@ -159,14 +179,14 @@ for the JavaScript code in this tag.
<li><a href="#sec-2-9"><code># contributor:</code> snippet author</a></li> <li><a href="#sec-2-9"><code># contributor:</code> snippet author</a></li>
</ul> </ul>
</li> </li>
<li><a href="#sec-3">Template syntax</a> <li><a href="#sec-3"></a>
<ul> <ul>
<li><a href="#sec-3-1">Plain Text</a></li> <li><a href="#sec-3-1">Plain Text</a></li>
<li><a href="#sec-3-2">Embedded Emacs-lisp code</a></li> <li><a href="#sec-3-2">Embedded Emacs-lisp code</a></li>
<li><a href="#sec-3-3">Tab stop fields</a></li> <li><a href="#sec-3-3">Tab stop fields</a></li>
<li><a href="#sec-3-4">Placeholder fields</a></li> <li><a href="#sec-3-4">Placeholder fields</a></li>
<li><a href="#sec-3-5">Mirrors</a></li> <li><a href="#sec-3-5"></a></li>
<li><a href="#sec-3-6">Mirrors with transformations</a></li> <li><a href="#sec-3-6">Mirrors with </a></li>
<li><a href="#sec-3-7">Fields with transformations</a></li> <li><a href="#sec-3-7">Fields with transformations</a></li>
<li><a href="#sec-3-8">Choosing fields value from a list and other tricks</a></li> <li><a href="#sec-3-8">Choosing fields value from a list and other tricks</a></li>
<li><a href="#sec-3-9">Nested placeholder fields</a></li> <li><a href="#sec-3-9">Nested placeholder fields</a></li>
@ -176,32 +196,31 @@ for the JavaScript code in this tag.
</div> </div>
</div> </div>
<div id="outline-container-1" class="outline-2"> <div id="outline-container-sec-1" class="outline-2">
<h2 id="sec-1">Snippet development</h2> <h2 id="sec-1">Snippet development</h2>
<div class="outline-text-2" id="text-1"> <div class="outline-text-2" id="text-1">
</div><div id="outline-container-sec-1-1" class="outline-3">
</div>
<div id="outline-container-1-1" class="outline-3">
<h3 id="sec-1-1">Quickly finding snippets</h3> <h3 id="sec-1-1">Quickly finding snippets</h3>
<div class="outline-text-3" id="text-1-1"> <div class="outline-text-3" id="text-1-1">
<p> <p>
There are some ways you can quickly find a snippet file: There are some ways you can quickly find a snippet file or create a new one:
</p> </p>
<ul>
<ul class="org-ul">
<li><code>M-x yas-new-snippet</code> <li><code>M-x yas-new-snippet</code>
<p> <p>
Prompts you for a snippet name, then tries to guess a suitable Creates a new buffer with a template for making a new snippet.
directory to store it, prompting you for creation if it does not The buffer is in <code>snippet-mode</code> (see below). When you are done
exist. Finally, places you in a new buffer set to <code>snippet-mode</code> so editing the new snippet, use <code>C-c C-c</code> to save it. This will
you can write your snippet. prompt for a directory two steps: first, the snippet table
(with a default based on the major mode you started in), and then
then snippet collection directory (defaults to the first directory
in <code>yas-snippet-dirs</code>. (See <a href="snippet-organization.html">Organizing Snippets</a>
for more detail on how snippets are organized.)
</p> </p>
</li> </li>
<li><code>M-x yas-find-snippets</code> <li><code>M-x yas-find-snippets</code>
<p> <p>
@ -210,38 +229,38 @@ There are some ways you can quickly find a snippet file:
directory searching logic is similar to <code>M-x yas-new-snippet</code>. directory searching logic is similar to <code>M-x yas-new-snippet</code>.
</p> </p>
</li> </li>
<li><code>M-x yas-visit-snippet-file</code> <li><code>M-x yas-visit-snippet-file</code>
<p> <p>
Prompts you for possible snippet expansions like Prompts you for possible snippet expansions like
<a href="snippet-reference.html#yas-insert-snippet"><code>yas-insert-snippet</code></a>, but instead of expanding it, takes you directly <a href="snippet-reference.html#yas-insert-snippet"><code>yas-insert-snippet</code></a>, but instead of expanding it, takes you directly
to the snippet definition's file, if it exists. to the snippet definition's file, if it exists.
</p></li> </p>
</li>
</ul> </ul>
<p> <p>
Once you find this file it will be set to <code>snippet-mode</code> (see ahead) and Once you find this file it will be set to <code>snippet-mode</code> (see ahead) and
you can start editing your snippet. you can start editing your snippet.
</p> </p>
</div> </div>
</div> </div>
<div id="outline-container-1-2" class="outline-3"> <div id="outline-container-sec-1-2" class="outline-3">
<h3 id="sec-1-2">Using the <code>snippet-mode</code> major mode</h3> <h3 id="sec-1-2">Using the <code>snippet-mode</code> major mode</h3>
<div class="outline-text-3" id="text-1-2"> <div class="outline-text-3" id="text-1-2">
<p> <p>
There is a major mode <code>snippet-mode</code> to edit snippets. You can set the There is a major mode <code>snippet-mode</code> to edit snippets. You can set the
buffer to this mode with <code>M-x snippet-mode</code>. It provides reasonably buffer to this mode with <code>M-x snippet-mode</code>. It provides reasonably
useful syntax highlighting. useful syntax highlighting.
</p> </p>
<p> <p>
Two commands are defined in this mode: Two commands are defined in this mode:
</p> </p>
<ul>
<ul class="org-ul">
<li><code>M-x yas-load-snippet-buffer</code> <li><code>M-x yas-load-snippet-buffer</code>
<p> <p>
@ -250,6 +269,7 @@ Two commands are defined in this mode:
<code>snippet-mode</code>. <code>snippet-mode</code>.
</p> </p>
</li> </li>
<li><code>M-x yas-tryout-snippet</code> <li><code>M-x yas-tryout-snippet</code>
<p> <p>
@ -257,28 +277,26 @@ Two commands are defined in this mode:
the appropriate major mode and inserts the snippet there, so you the appropriate major mode and inserts the snippet there, so you
can see what it looks like. This is bound to <code>C-c C-t</code> while in can see what it looks like. This is bound to <code>C-c C-t</code> while in
<code>snippet-mode</code>. <code>snippet-mode</code>.
</p></li> </p>
</li>
</ul> </ul>
<p> <p>
There are also <i>snippets for writing snippets</i>: <code>vars</code>, <code>$f</code> and <code>$m</code> There are also <i>snippets for writing snippets</i>: <code>vars</code>, <code>$f</code> and <code>$m</code>
:-). :-).
</p> </p>
</div> </div>
</div> </div>
</div> </div>
<div id="outline-container-2" class="outline-2"> <div id="outline-container-sec-2" class="outline-2">
<h2 id="sec-2">File content</h2> <h2 id="sec-2">File content</h2>
<div class="outline-text-2" id="text-2"> <div class="outline-text-2" id="text-2">
<p> <p>
A file defining a snippet generally contains the template to be A file defining a snippet generally contains the template to be
expanded. expanded.
</p> </p>
<p> <p>
Optionally, if the file contains a line of <code># --</code>, the lines above it Optionally, if the file contains a line of <code># --</code>, the lines above it
count as comments, some of which can be <i>directives</i> (or meta data). count as comments, some of which can be <i>directives</i> (or meta data).
@ -286,30 +304,28 @@ Snippet directives look like <code># property: value</code> and tweak certain
snippets properties described below. If no <code># --</code> is found, the whole snippets properties described below. If no <code># --</code> is found, the whole
file is considered the snippet template. file is considered the snippet template.
</p> </p>
<p> <p>
Here's a typical example: Here's a typical example:
</p> </p>
<div class="org-src-container">
<pre class="src src-snippet"># contributor: pluskid &lt;pluskid@gmail.com&gt;
<pre class="example"># contributor: pluskid &lt;pluskid@gmail.com&gt;
# name: __...__ # name: __...__
# -- # --
__${init}__ __${init}__
</pre> </pre>
</div>
<p> <p>
Here's a list of currently supported directives: Here's a list of currently supported directives:
</p> </p>
</div> </div>
<div id="outline-container-2-1" class="outline-3"> <div id="outline-container-sec-2-1" class="outline-3">
<h3 id="sec-2-1"><code># key:</code> snippet abbrev</h3> <h3 id="sec-2-1"><code># key:</code> snippet abbrev</h3>
<div class="outline-text-3" id="text-2-1"> <div class="outline-text-3" id="text-2-1">
<p> <p>
This is the probably the most important directive, it's the This is the probably the most important directive, it's the
abbreviation you type to expand a snippet just before hitting the key abbreviation you type to expand a snippet just before hitting the key
@ -317,55 +333,49 @@ that runs <a href="snippet-reference.html#yas-expand"><code>yas-expand</code></a
the snippet will not be expandable through the trigger mechanism. the snippet will not be expandable through the trigger mechanism.
</p> </p>
</div> </div>
</div> </div>
<div id="outline-container-2-2" class="outline-3"> <div id="outline-container-sec-2-2" class="outline-3">
<h3 id="sec-2-2"><code># name:</code> snippet name</h3> <h3 id="sec-2-2"><code># name:</code> snippet name</h3>
<div class="outline-text-3" id="text-2-2"> <div class="outline-text-3" id="text-2-2">
<p> <p>
This is a one-line description of the snippet. It will be displayed in This is a one-line description of the snippet. It will be displayed in
the menu. It's a good idea to select a descriptive name for a snippet -- the menu. It's a good idea to select a descriptive name for a snippet &#x2013;
especially distinguishable among similar snippets. especially distinguishable among similar snippets.
</p> </p>
<p> <p>
If you omit this name it will default to the file name the snippet was If you omit this name it will default to the file name the snippet was
loaded from. loaded from.
</p> </p>
</div> </div>
</div> </div>
<div id="outline-container-2-3" class="outline-3"> <div id="outline-container-sec-2-3" class="outline-3">
<h3 id="sec-2-3"><code># condition:</code> snippet condition</h3> <h3 id="sec-2-3"><code># condition:</code> snippet condition</h3>
<div class="outline-text-3" id="text-2-3"> <div class="outline-text-3" id="text-2-3">
<p> <p>
This is a piece of Emacs-lisp code. If a snippet has a condition, then This is a piece of Emacs-lisp code. If a snippet has a condition, then
it will only be expanded when the condition code evaluate to some it will only be expanded when the condition code evaluate to some
non-nil value. non-nil value.
</p> </p>
<p> <p>
See also <a href="snippet-reference.html#yas-buffer-local-condition"><code>yas-buffer-local-condition</code></a> in See also <a href="snippet-reference.html#yas-buffer-local-condition"><code>yas-buffer-local-condition</code></a> in
<a href="./snippet-expansion.html">Expanding snippets</a> <a href="./snippet-expansion.html">Expanding snippets</a>
</p> </p>
</div> </div>
</div> </div>
<div id="outline-container-2-4" class="outline-3"> <div id="outline-container-sec-2-4" class="outline-3">
<h3 id="sec-2-4"><code># group:</code> snippet menu grouping</h3> <h3 id="sec-2-4"><code># group:</code> snippet menu grouping</h3>
<div class="outline-text-3" id="text-2-4"> <div class="outline-text-3" id="text-2-4">
<p> <p>
When expanding/visiting snippets from the menu-bar menu, snippets for a When expanding/visiting snippets from the menu-bar menu, snippets for a
given mode can be grouped into sub-menus . This is useful if one has too given mode can be grouped into sub-menus . This is useful if one has too
many snippets for a mode which will make the menu too long. many snippets for a mode which will make the menu too long.
</p> </p>
<p> <p>
The <code># group:</code> property only affect menu construction (See The <code># group:</code> property only affect menu construction (See
<a href="./snippet-menu.html">the YASnippet menu</a>) and the same effect can be <a href="./snippet-menu.html">the YASnippet menu</a>) and the same effect can be
@ -373,6 +383,7 @@ achieved by grouping snippets into sub-directories and using the
<code>.yas-make-groups</code> special file (for this see <code>.yas-make-groups</code> special file (for this see
<a href="./snippet-organization.html">Organizing Snippets</a> <a href="./snippet-organization.html">Organizing Snippets</a>
</p> </p>
<p> <p>
Refer to the bundled snippets for <code>ruby-mode</code> for examples on the Refer to the bundled snippets for <code>ruby-mode</code> for examples on the
<code># group:</code> directive. Group can also be nested, e.g. <code># group:</code> directive. Group can also be nested, e.g.
@ -380,22 +391,22 @@ Refer to the bundled snippets for <code>ruby-mode</code> for examples on the
group which is under the <code>control structure</code> group. group which is under the <code>control structure</code> group.
</p> </p>
</div> </div>
</div> </div>
<div id="outline-container-2-5" class="outline-3"> <div id="outline-container-sec-2-5" class="outline-3">
<h3 id="sec-2-5"><code># expand-env:</code> expand environment</h3> <h3 id="sec-2-5"><code># expand-env:</code> expand environment</h3>
<div class="outline-text-3" id="text-2-5"> <div class="outline-text-3" id="text-2-5">
<p> <p>
This is another piece of Emacs-lisp code in the form of a <code>let</code> <i>varlist form</i>, i.e. a list of lists assigning values to variables. It can be This is another piece of Emacs-lisp code in the form of a <code>let</code> <i>varlist
form</i>, i.e. a list of lists assigning values to variables. It can be
used to override variable values while the snippet is being expanded. used to override variable values while the snippet is being expanded.
</p> </p>
<p> <p>
Interesting variables to override are <a href="snippet-reference.html#yas-wrap-around-region"><code>yas-wrap-around-region</code></a> and Interesting variables to override are <a href="snippet-reference.html#yas-wrap-around-region"><code>yas-wrap-around-region</code></a> and
<a href="snippet-reference.html#yas-indent-line"><code>yas-indent-line</code></a> (see <a href="./snippet-expansion.html">Expanding Snippets</a>). <a href="snippet-reference.html#yas-indent-line"><code>yas-indent-line</code></a> (see <a href="./snippet-expansion.html">Expanding Snippets</a>).
</p> </p>
<p> <p>
As an example, you might normally have <a href="snippet-reference.html#yas-indent-line"><code>yas-indent-line</code></a> set to '<code>auto</code> As an example, you might normally have <a href="snippet-reference.html#yas-indent-line"><code>yas-indent-line</code></a> set to '<code>auto</code>
and <a href="snippet-reference.html#yas-wrap-around-region"><code>yas-wrap-around-region</code></a> set to <code>t</code>, but for this particularly and <a href="snippet-reference.html#yas-wrap-around-region"><code>yas-wrap-around-region</code></a> set to <code>t</code>, but for this particularly
@ -403,9 +414,9 @@ brilliant piece of ASCII art these values would mess up your hard work.
You can then use: You can then use:
</p> </p>
<div class="org-src-container">
<pre class="src src-snippet"># name: ASCII home
<pre class="example"># name: ASCII home
# expand-env: ((yas-indent-line 'fixed) (yas-wrap-around-region 'nil)) # expand-env: ((yas-indent-line 'fixed) (yas-wrap-around-region 'nil))
# -- # --
welcome to my welcome to my
@ -419,36 +430,33 @@ You can then use:
| | | | | | | |
+--+-+--+ +--+-+--+
</pre> </pre>
</div>
</div>
</div> </div>
</div> <div id="outline-container-sec-2-6" class="outline-3">
<div id="outline-container-2-6" class="outline-3">
<h3 id="sec-2-6"><code># binding:</code> direct keybinding</h3> <h3 id="sec-2-6"><code># binding:</code> direct keybinding</h3>
<div class="outline-text-3" id="text-2-6"> <div class="outline-text-3" id="text-2-6">
<p> <p>
You can use this directive to expand a snippet directly from a normal You can use this directive to expand a snippet directly from a normal
Emacs keybinding. The keybinding will be registered in the Emacs keymap Emacs keybinding. The keybinding will be registered in the Emacs keymap
named after the major mode the snippet is active for. named after the major mode the snippet is active for.
</p> </p>
<p> <p>
Additionally a variable <a href="snippet-reference.html#yas-prefix"><code>yas-prefix</code></a> is set to to the prefix argument Additionally a variable <a href="snippet-reference.html#yas-prefix"><code>yas-prefix</code></a> is set to to the prefix argument
you normally use for a command. This allows for small variations on the you normally use for a command. This allows for small variations on the
same snippet, for example in this "html-mode" snippet. same snippet, for example in this "html-mode" snippet.
</p> </p>
<div class="org-src-container">
<pre class="src src-snippet"># name: &lt;p&gt;...&lt;/p&gt;
<pre class="example"># name: &lt;p&gt;...&lt;/p&gt;
# binding: C-c C-c C-m # binding: C-c C-c C-m
# -- # --
&lt;p&gt;`(when yas-prefix "\n")`$0`(when yas-prefix "\n")`&lt;/p&gt; &lt;p&gt;`(when yas-prefix "\n")`$0`(when yas-prefix "\n")`&lt;/p&gt;
</pre> </pre>
</div>
<p> <p>
This binding will be recorded in the keymap <code>html-mode-map</code>. To expand a This binding will be recorded in the keymap <code>html-mode-map</code>. To expand a
@ -456,73 +464,59 @@ paragraph tag newlines, just press <code>C-u C-c C-c C-m</code>. Omitting the <c
will expand the paragraph tag without newlines. will expand the paragraph tag without newlines.
</p> </p>
</div> </div>
</div> </div>
<div id="outline-container-2-7" class="outline-3"> <div id="outline-container-sec-2-7" class="outline-3">
<h3 id="sec-2-7"><code># type:</code> <code>snippet</code> or <code>command</code></h3> <h3 id="sec-2-7"><code># type:</code> <code>snippet</code> or <code>command</code></h3>
<div class="outline-text-3" id="text-2-7"> <div class="outline-text-3" id="text-2-7">
<p> <p>
If the <code>type</code> directive is set to <code>command</code>, the body of the snippet If the <code>type</code> directive is set to <code>command</code>, the body of the snippet
is interpreted as lisp code to be evaluated when the snippet is is interpreted as lisp code to be evaluated when the snippet is
triggered. triggered.
</p> </p>
<p> <p>
If it's <code>snippet</code> (the default when there is no <code>type</code> directive), the If it's <code>snippet</code> (the default when there is no <code>type</code> directive), the
snippet body will be parsed according to the <a href="#sec-3">Template Syntax</a>, snippet body will be parsed according to the <i>Template Syntax</i>,
described below. described below.
</p> </p>
</div> </div>
</div> </div>
<div id="outline-container-2-8" class="outline-3"> <div id="outline-container-sec-2-8" class="outline-3">
<h3 id="sec-2-8"><code># uuid:</code> unique identifier</h3> <h3 id="sec-2-8"><code># uuid:</code> unique identifier</h3>
<div class="outline-text-3" id="text-2-8"> <div class="outline-text-3" id="text-2-8">
<p> <p>
This provides to a way to identify a snippet, independent of its name. This provides to a way to identify a snippet, independent of its name.
Loading a second snippet file with the same uuid would replace the Loading a second snippet file with the same uuid would replace the
previous snippet. previous snippet.
</p> </p>
</div> </div>
</div> </div>
<div id="outline-container-2-9" class="outline-3"> <div id="outline-container-sec-2-9" class="outline-3">
<h3 id="sec-2-9"><code># contributor:</code> snippet author</h3> <h3 id="sec-2-9"><code># contributor:</code> snippet author</h3>
<div class="outline-text-3" id="text-2-9"> <div class="outline-text-3" id="text-2-9">
<p> <p>
This is optional and has no effect whatsoever on snippet functionality, This is optional and has no effect whatsoever on snippet functionality,
but it looks nice. but it looks nice.
</p> </p>
</div> </div>
</div> </div>
</div> </div>
<div id="outline-container-3" class="outline-2"> <div id="outline-container-sec-3" class="outline-2">
<h2 id="sec-3"><span class="target">Template syntax</span></h2> <h2 id="sec-3"><a id="Template-syntax" name="Template-syntax"></a></h2>
<div class="outline-text-2" id="text-3"> <div class="outline-text-2" id="text-3">
<p> <p>
The syntax of the snippet template is simple but powerful, very similar The syntax of the snippet template is simple but powerful, very similar
to TextMate's. to TextMate's.
</p> </p>
</div> </div>
<div id="outline-container-3-1" class="outline-3"> <div id="outline-container-sec-3-1" class="outline-3">
<h3 id="sec-3-1">Plain Text</h3> <h3 id="sec-3-1">Plain Text</h3>
<div class="outline-text-3" id="text-3-1"> <div class="outline-text-3" id="text-3-1">
<p> <p>
Arbitrary text can be included as the content of a template. They are Arbitrary text can be included as the content of a template. They are
usually interpreted as plain text, except <code>$</code> and <code>`</code>. You need to usually interpreted as plain text, except <code>$</code> and <code>`</code>. You need to
@ -530,35 +524,33 @@ use <code>\</code> to escape them: <code>\$</code> and <code>\`</code>. The <cod
escaped as <code>\\</code> sometimes. escaped as <code>\\</code> sometimes.
</p> </p>
</div> </div>
</div> </div>
<div id="outline-container-3-2" class="outline-3"> <div id="outline-container-sec-3-2" class="outline-3">
<h3 id="sec-3-2">Embedded Emacs-lisp code</h3> <h3 id="sec-3-2">Embedded Emacs-lisp code</h3>
<div class="outline-text-3" id="text-3-2"> <div class="outline-text-3" id="text-3-2">
<p> <p>
Emacs-Lisp code can be embedded inside the template, written inside Emacs-Lisp code can be embedded inside the template, written inside
back-quotes (<code>`</code>). The lisp forms are evaluated when the snippet is back-quotes (<code>`</code>). The lisp forms are evaluated when the snippet is
being expanded. The evaluation is done in the same buffer as the being expanded. The evaluation is done in the same buffer as the
snippet being expanded. snippet being expanded.
</p> </p>
<p> <p>
Here's an example for c-mode` to calculate the header file guard Here's an example for c-mode` to calculate the header file guard
dynamically: dynamically:
</p> </p>
<div class="org-src-container">
<pre class="src src-snippet">#ifndef ${1:_`(upcase (file-name-nondirectory (file-name-sans-extension (buffer-file-name))))`_H_}
<pre class="example">#ifndef ${1:_`(upcase (file-name-nondirectory (file-name-sans-extension (buffer-file-name))))`_H_}
#define $1 #define $1
$0 $0
#endif /* $1 */ #endif /* $1 */
</pre> </pre>
</div>
<p> <p>
From version 0.6, snippets expansions are run with some special From version 0.6, snippets expansions are run with some special
@ -566,13 +558,13 @@ Emacs-lisp variables bound. One of this is <a href="snippet-reference.html#yas-s
therefore define a snippet like: therefore define a snippet like:
</p> </p>
<div class="org-src-container">
<pre class="src src-snippet">for ($1;$2;$3) {
<pre class="example">for ($1;$2;$3) {
`yas-selected-text`$0 `yas-selected-text`$0
} }
</pre> </pre>
</div>
<p> <p>
to "wrap" the selected region inside your recently inserted snippet. to "wrap" the selected region inside your recently inserted snippet.
@ -580,14 +572,11 @@ Alternatively, you can also customize the variable
<a href="snippet-reference.html#yas-wrap-around-region"><code>yas-wrap-around-region</code></a> to <code>t</code> which will do this automatically. <a href="snippet-reference.html#yas-wrap-around-region"><code>yas-wrap-around-region</code></a> to <code>t</code> which will do this automatically.
</p> </p>
</div> </div>
</div> </div>
<div id="outline-container-3-3" class="outline-3"> <div id="outline-container-sec-3-3" class="outline-3">
<h3 id="sec-3-3">Tab stop fields</h3> <h3 id="sec-3-3">Tab stop fields</h3>
<div class="outline-text-3" id="text-3-3"> <div class="outline-text-3" id="text-3-3">
<p> <p>
Tab stops are fields that you can navigate back and forth by <code>TAB</code> and Tab stops are fields that you can navigate back and forth by <code>TAB</code> and
<code>S-TAB</code>. They are written by <code>$</code> followed with a number. <code>$0</code> has the <code>S-TAB</code>. They are written by <code>$</code> followed with a number. <code>$0</code> has the
@ -595,81 +584,72 @@ special meaning of the <i>exit point</i> of a snippet. That is the last place
to go when you've traveled all the fields. Here's a typical example: to go when you've traveled all the fields. Here's a typical example:
</p> </p>
<div class="org-src-container">
<pre class="src src-snippet">&lt;div$1&gt;
<pre class="example">&lt;div$1&gt;
$0 $0
&lt;/div&gt; &lt;/div&gt;
</pre> </pre>
</div> </div>
</div> </div>
</div>
<div id="outline-container-3-4" class="outline-3"> <div id="outline-container-sec-3-4" class="outline-3">
<h3 id="sec-3-4">Placeholder fields</h3> <h3 id="sec-3-4">Placeholder fields</h3>
<div class="outline-text-3" id="text-3-4"> <div class="outline-text-3" id="text-3-4">
<p> <p>
Tab stops can have default values &ndash; a.k.a placeholders. The syntax is Tab stops can have default values &#x2013; a.k.a placeholders. The syntax is
like this: like this:
</p> </p>
<div class="org-src-container">
<pre class="src src-snippet">${N:default value}
<pre class="example">${N:default value}
</pre> </pre>
</div>
<p> <p>
They acts as the default value for a tab stop. But when you firstly They acts as the default value for a tab stop. But when you firstly
type at a tab stop, the default value will be replaced by your typing. type at a tab stop, the default value will be replaced by your typing.
The number can be omitted if you don't want to create <a href="#sec-3-5">mirrors</a> or The number can be omitted if you don't want to create <i>mirrors</i> or
<a href="#sec-3-6">transformations</a> for this field. <a href="#transformations">3.6</a> for this field.
</p> </p>
</div> </div>
</div> </div>
<div id="outline-container-3-5" class="outline-3"> <div id="outline-container-sec-3-5" class="outline-3">
<h3 id="sec-3-5"><span class="target">Mirrors</span></h3> <h3 id="sec-3-5"><a id="Mirrors" name="Mirrors"></a></h3>
<div class="outline-text-3" id="text-3-5"> <div class="outline-text-3" id="text-3-5">
<p> <p>
We refer the tab stops with placeholders as a <i>field</i>. A field can have We refer the tab stops with placeholders as a <i>field</i>. A field can have
mirrors. Its mirrors will get updated when you change the text of a mirrors. Its mirrors will get updated when you change the text of a
field. Here's an example: field. Here's an example:
</p> </p>
<div class="org-src-container">
<pre class="src src-snippet">\begin{${1:enumerate}}
<pre class="example">\begin{${1:enumerate}}
$0 $0
\end{$1} \end{$1}
</pre> </pre>
</div>
<p> <p>
When you type "document" at <code>${1:enumerate}</code>, the word "document" will When you type "document" at <code>${1:enumerate}</code>, the word "document" will
also be inserted at <code>\end{$1}</code>. The best explanation is to see the also be inserted at <code>\end{$1}</code>. The best explanation is to see the
screencast(<a href="http://www.youtube.com/watch?v=vOj7btx3ATg">YouTube</a> or <a href="http://yasnippet.googlecode.com/files/yasnippet.avi">avi video</a>). screencast(<a href="http://www.youtube.com/watch?v=vOj7btx3ATg">YouTube</a> or <a href="http://yasnippet.googlecode.com/files/yasnippet.avi">avi video</a>).
</p> </p>
<p> <p>
The tab stops with the same number to the field act as its mirrors. If The tab stops with the same number to the field act as its mirrors. If
none of the tab stops has an initial value, the first one is selected as none of the tab stops has an initial value, the first one is selected as
the field and others mirrors. the field and others mirrors.
</p> </p>
</div> </div>
</div> </div>
<div id="outline-container-3-6" class="outline-3"> <div id="outline-container-sec-3-6" class="outline-3">
<h3 id="sec-3-6">Mirrors with <span class="target">transformations</span></h3> <h3 id="sec-3-6">Mirrors with <a id="transformations" name="transformations"></a></h3>
<div class="outline-text-3" id="text-3-6"> <div class="outline-text-3" id="text-3-6">
<p> <p>
If the value of an <code>${n:</code>-construct starts with and contains <code>$(</code>, If the value of an <code>${n:</code>-construct starts with and contains <code>$(</code>,
then it is interpreted as a mirror for field <code>n</code> with a then it is interpreted as a mirror for field <code>n</code> with a
@ -680,9 +660,9 @@ content (string) contained in the field <code>n</code>. Here's an example for
Objective-C: Objective-C:
</p> </p>
<div class="org-src-container">
<pre class="src src-snippet">- (${1:id})${2:foo}
<pre class="example">- (${1:id})${2:foo}
{ {
return $2; return $2;
} }
@ -694,7 +674,7 @@ Objective-C:
} }
$0 $0
</pre> </pre>
</div>
<p> <p>
Look at <code>${2:$(capitalize yas-text)}</code>, it is a mirror with Look at <code>${2:$(capitalize yas-text)}</code>, it is a mirror with
@ -705,86 +685,85 @@ transformed text. So in this example, if you type "baz" in the field,
the transformed text will be "Baz". This example is also available in the transformed text will be "Baz". This example is also available in
the screencast. the screencast.
</p> </p>
<p> <p>
Another example is for <code>rst-mode</code>. In reStructuredText, the document Another example is for <code>rst-mode</code>. In reStructuredText, the document
title can be some text surrounded by "===" below and above. The "===" title can be some text surrounded by "<code>=</code>" below and above. The "<code>=</code>"
should be at least as long as the text. So should be at least as long as the text. So
</p> </p>
<div class="org-src-container">
<pre class="src src-rst">=====
<pre class="example">=====
Title Title
===== =====
</pre> </pre>
</div>
<p> <p>
is a valid title but is a valid title but
</p> </p>
<div class="org-src-container">
<pre class="src src-rst">===
<pre class="example">===
Title Title
=== ===
</pre> </pre>
</div>
<p> <p>
is not. Here's an snippet for rst title: is not. Here's an snippet for rst title:
</p> </p>
<div class="org-src-container">
<pre class="src src-snippet">${1:$(make-string (string-width yas-text) ?\=)}
<pre class="example">${1:$(make-string (string-width yas-text) ?\=)}
${1:Title} ${1:Title}
${1:$(make-string (string-width yas-text) ?\=)} ${1:$(make-string (string-width yas-text) ?\=)}
$0 $0
</pre> </pre>
</div>
</div>
</div> </div>
</div> <div id="outline-container-sec-3-7" class="outline-3">
<div id="outline-container-3-7" class="outline-3">
<h3 id="sec-3-7">Fields with transformations</h3> <h3 id="sec-3-7">Fields with transformations</h3>
<div class="outline-text-3" id="text-3-7"> <div class="outline-text-3" id="text-3-7">
<p> <p>
From version 0.6 on, you can also have lisp transformation inside From version 0.6 on, you can also have lisp transformation inside
fields. These work mostly mirror transformations but are evaluated when fields. These work mostly mirror transformations but are evaluated when
you first enter the field, after each change you make to the field and you first enter the field, after each change you make to the field and
also just before you exit the field. also just before you exit the field.
</p> </p>
<p> <p>
The syntax is also a tiny bit different, so that the parser can The syntax is also a tiny bit different, so that the parser can
distinguish between fields and mirrors. In the following example distinguish between fields and mirrors. In the following example
</p> </p>
<pre class="example"> <pre class="example">
#define "${1:mydefine$(upcase yas-text)}" #define "${1:mydefine$(upcase yas-text)}"
</pre> </pre>
<p> <p>
<code>mydefine</code> gets automatically upcased to <code>MYDEFINE</code> once you enter the <code>mydefine</code> gets automatically upcased to <code>MYDEFINE</code> once you enter the
field. As you type text, it gets filtered through the transformation field. As you type text, it gets filtered through the transformation
every time. every time.
</p> </p>
<p> <p>
Note that to tell this kind of expression from a mirror with a Note that to tell this kind of expression from a mirror with a
transformation, YASnippet needs extra text between the <code>:</code> and the transformation, YASnippet needs extra text between the <code>:</code> and the
transformation's <code>$</code>. If you don't want this extra-text, you can use two transformation's <code>$</code>. If you don't want this extra-text, you can use two
<code>$</code>'s instead. <code>$</code>'s instead.
</p> </p>
<pre class="example"> <pre class="example">
#define "${1:$$(upcase yas-text)}" #define "${1:$$(upcase yas-text)}"
</pre> </pre>
<p> <p>
Please note that as soon as a transformation takes place, it changes the Please note that as soon as a transformation takes place, it changes the
value of the field and sets it its internal modification state to value of the field and sets it its internal modification state to
@ -792,14 +771,11 @@ value of the field and sets it its internal modification state to
does not take place. This is by design. does not take place. This is by design.
</p> </p>
</div> </div>
</div> </div>
<div id="outline-container-3-8" class="outline-3"> <div id="outline-container-sec-3-8" class="outline-3">
<h3 id="sec-3-8">Choosing fields value from a list and other tricks</h3> <h3 id="sec-3-8">Choosing fields value from a list and other tricks</h3>
<div class="outline-text-3" id="text-3-8"> <div class="outline-text-3" id="text-3-8">
<p> <p>
As mentioned, the field transformation is invoked just after you enter As mentioned, the field transformation is invoked just after you enter
the field, and with some useful variables bound, notably the field, and with some useful variables bound, notably
@ -807,80 +783,79 @@ the field, and with some useful variables bound, notably
can place a transformation in the primary field that lets you select can place a transformation in the primary field that lets you select
default values for it. default values for it.
</p> </p>
<p> <p>
The <a href="snippet-reference.html#yas-choose-value"><code>yas-choose-value</code></a> does this work for you. For example: The <a href="snippet-reference.html#yas-choose-value"><code>yas-choose-value</code></a> does this work for you. For example:
</p> </p>
<div class="org-src-container">
<pre class="src src-snippet">&lt;div align="${2:$$(yas-choose-value '("right" "center" "left"))}"&gt;
<pre class="example">&lt;div align="${2:$$(yas-choose-value '("right" "center" "left"))}"&gt;
$0 $0
&lt;/div&gt; &lt;/div&gt;
</pre> </pre>
</div>
<p> <p>
See the definition of <a href="snippet-reference.html#yas-choose-value"><code>yas-choose-value</code></a> to see how it was written using See the definition of <a href="snippet-reference.html#yas-choose-value"><code>yas-choose-value</code></a> to see how it was written using
the two variables. the two variables.
</p> </p>
<p> <p>
Here's another use, for LaTeX-mode, which calls reftex-label just as you Here's another use, for LaTeX-mode, which calls reftex-label just as you
enter snippet field 2. This one makes use of <a href="snippet-reference.html#yas-modified-p"><code>yas-modified-p</code></a> directly. enter snippet field 2. This one makes use of <a href="snippet-reference.html#yas-modified-p"><code>yas-modified-p</code></a> directly.
</p> </p>
<div class="org-src-container">
<pre class="src src-snippet">\section{${1:"Titel der Tour"}}%
<pre class="example">\section{${1:"Titel der Tour"}}%
\index{$1}% \index{$1}%
\label{{2:"waiting for reftex-label call..."$(unless yas-modified-p (reftex-label nil 'dont- \label{{2:"waiting for reftex-label call..."$(unless yas-modified-p (reftex-label nil 'dont-
insert))}}% insert))}}%
</pre> </pre>
</div>
<p> <p>
The function <a href="snippet-reference.html#yas-verify-value"><code>yas-verify-value</code></a> has another neat trick, and makes use The function <a href="snippet-reference.html#yas-verify-value"><code>yas-verify-value</code></a> has another neat trick, and makes use
of <a href="snippet-reference.html#yas-moving-away-p"><code>yas-moving-away-p</code></a>. Try it and see! Also, check out this <a href="http://groups.google.com/group/smart-snippet/browse_thread/thread/282a90a118e1b662">thread</a> of <a href="snippet-reference.html#yas-moving-away-p"><code>yas-moving-away-p</code></a>. Try it and see! Also, check out this <a href="http://groups.google.com/group/smart-snippet/browse_thread/thread/282a90a118e1b662">thread</a>
</p> </p>
</div> </div>
</div> </div>
<div id="outline-container-3-9" class="outline-3"> <div id="outline-container-sec-3-9" class="outline-3">
<h3 id="sec-3-9">Nested placeholder fields</h3> <h3 id="sec-3-9">Nested placeholder fields</h3>
<div class="outline-text-3" id="text-3-9"> <div class="outline-text-3" id="text-3-9">
<p> <p>
From version 0.6 on, you can also have nested placeholders of the type: From version 0.6 on, you can also have nested placeholders of the type:
</p> </p>
<div class="org-src-container">
<pre class="src src-snippet">&lt;div${1: id="${2:some_id}"}&gt;$0&lt;/div&gt;
<pre class="example">&lt;div${1: id="${2:some_id}"}&gt;$0&lt;/div&gt;
</pre> </pre>
</div>
<p> <p>
This allows you to choose if you want to give this <code>div</code> an <code>id</code> This allows you to choose if you want to give this <code>div</code> an <code>id</code>
attribute. If you tab forward after expanding it will let you change attribute. If you tab forward after expanding it will let you change
"some_id" to whatever you like. Alternatively, you can just press <code>C-d</code> "some\<sub>id</sub>" to whatever you like. Alternatively, you can just press <code>C-d</code>
(which executes <a href="snippet-reference.html#yas-skip-and-clear-or-delete-char"><code>yas-skip-and-clear-or-delete-char</code></a>) and go straight to (which executes <a href="snippet-reference.html#yas-skip-and-clear-or-delete-char"><code>yas-skip-and-clear-or-delete-char</code></a>) and go straight to
the exit marker. the exit marker.
</p> </p>
<p> <p>
By the way, <code>C-d</code> will only clear the field if you cursor is at the By the way, <code>C-d</code> will only clear the field if you cursor is at the
beginning of the field <i>and</i> it hasn't been changed yet. Otherwise, it beginning of the field <i>and</i> it hasn't been changed yet. Otherwise, it
performs the normal Emacs <code>delete-char</code> command. performs the normal Emacs <code>delete-char</code> command.
</p></div>
</div>
</div>
</div>
<div id="postamble">
<hr><p class='creator'>Generated by <a href="http://orgmode.org">Org</a> version 7.9.3f with <a href="http://www.gnu.org/software/emacs/">Emacs</a> version 24 on 2014-10-01T21:16+0100 from 08b044e559cc350c6e7142d088ec2d4a82e378cb
</p> </p>
<p class='xhtml-validation'><a href="http://validator.w3.org/check?uri=referer">Validate XHTML 1.0</a></p> </div>
</div>
</div>
</div>
<div id="postamble" class="status">
<hr><p class='creator'>Generated by <a href="http://www.gnu.org/software/emacs/">Emacs</a> 24.4.91.1 (<a href="http://orgmode.org">Org</a> mode 8.2.10) on from 7703a55ac416a131dec45fa6a1e0ec1e31adf760
</p>
<p class='xhtml-validation'><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
</div> </div>
</body> </body>
</html> </html>

View File

@ -1,39 +1,61 @@
<?xml version="1.0" encoding="iso-8859-1"?> <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head> <head>
<title>Expanding snippets</title> <title>Expanding snippets</title>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"/> <!-- 2015-09-24 Thu 21:14 -->
<meta name="title" content="Expanding snippets"/> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="generator" content="Org-mode" /> <meta name="generator" content="Org-mode" />
<meta name="generated" content="2014-10-01T21:16+0100"/>
<meta name="author" content=""/>
<meta name="description" content=""/>
<meta name="keywords" content=""/>
<style type="text/css"> <style type="text/css">
<!--/*--><![CDATA[/*><!--*/ <!--/*--><![CDATA[/*><!--*/
html { font-family: Times, serif; font-size: 12pt; }
.title { text-align: center; } .title { text-align: center; }
.todo { color: red; } .todo { font-family: monospace; color: red; }
.done { color: green; } .done { color: green; }
.tag { background-color: #add8e6; font-weight:normal } .tag { background-color: #eee; font-family: monospace;
.target { } padding: 2px; font-size: 80%; font-weight: normal; }
.timestamp { color: #bebebe; } .timestamp { color: #bebebe; }
.timestamp-kwd { color: #5f9ea0; } .timestamp-kwd { color: #5f9ea0; }
.right { margin-left: auto; margin-right: 0px; text-align: right; } .right { margin-left: auto; margin-right: 0px; text-align: right; }
.left { margin-left: 0px; margin-right: auto; text-align: left; } .left { margin-left: 0px; margin-right: auto; text-align: left; }
.center { margin-left: auto; margin-right: auto; text-align: center; } .center { margin-left: auto; margin-right: auto; text-align: center; }
p.verse { margin-left: 3% } .underline { text-decoration: underline; }
#postamble p, #preamble p { font-size: 90%; margin: .2em; }
p.verse { margin-left: 3%; }
pre { pre {
border: 1pt solid #AEBDCC; border: 1px solid #ccc;
background-color: #F3F5F7; box-shadow: 3px 3px 3px #eee;
padding: 5pt; padding: 8pt;
font-family: courier, monospace; font-family: monospace;
font-size: 90%;
overflow: auto; overflow: auto;
margin: 1.2em;
} }
pre.src {
position: relative;
overflow: visible;
padding-top: 1.2em;
}
pre.src:before {
display: none;
position: absolute;
background-color: white;
top: -10px;
right: 10px;
padding: 3px;
border: 1px solid black;
}
pre.src:hover:before { display: inline;}
pre.src-sh:before { content: 'sh'; }
pre.src-bash:before { content: 'sh'; }
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
pre.src-R:before { content: 'R'; }
pre.src-perl:before { content: 'Perl'; }
pre.src-java:before { content: 'Java'; }
pre.src-sql:before { content: 'SQL'; }
table { border-collapse:collapse; } table { border-collapse:collapse; }
caption.t-above { caption-side: top; }
caption.t-bottom { caption-side: bottom; }
td, th { vertical-align:top; } td, th { vertical-align:top; }
th.right { text-align: center; } th.right { text-align: center; }
th.left { text-align: center; } th.left { text-align: center; }
@ -42,22 +64,27 @@
td.left { text-align: left; } td.left { text-align: left; }
td.center { text-align: center; } td.center { text-align: center; }
dt { font-weight: bold; } dt { font-weight: bold; }
div.figure { padding: 0.5em; } .footpara:nth-child(2) { display: inline; }
div.figure p { text-align: center; } .footpara { display: block; }
div.inlinetask { .footdef { margin-bottom: 1em; }
.figure { padding: 1em; }
.figure p { text-align: center; }
.inlinetask {
padding: 10px; padding: 10px;
border: 2px solid gray; border: 2px solid gray;
margin: 10px; margin: 10px;
background: #ffffcc; background: #ffffcc;
} }
#org-div-home-and-up
{ text-align: right; font-size: 70%; white-space: nowrap; }
textarea { overflow-x: auto; } textarea { overflow-x: auto; }
.linenr { font-size: smaller } .linenr { font-size: smaller }
.code-highlighted { background-color: #ffff00; } .code-highlighted { background-color: #ffff00; }
.org-info-js_info-navigation { border-style: none; } .org-info-js_info-navigation { border-style: none; }
#org-info-js_console-label { font-size:10px; font-weight:bold; #org-info-js_console-label
white-space:nowrap; } { font-size: 10px; font-weight: bold; white-space: nowrap; }
.org-info-js_search-highlight {background-color:#ffff00; color:#000000; .org-info-js_search-highlight
font-weight:bold; } { background-color: #ffff00; color: #000000; font-weight: bold; }
/*]]>*/--> /*]]>*/-->
</style> </style>
<link rel="stylesheet" type="text/css" href="stylesheets/manual.css" /> <link rel="stylesheet" type="text/css" href="stylesheets/manual.css" />
@ -107,11 +134,9 @@ for the JavaScript code in this tag.
} }
/*]]>*///--> /*]]>*///-->
</script> </script>
</head> </head>
<body> <body>
<div id="preamble" class="status">
<div id="preamble">
<nav> <nav>
<ul class="center"> <ul class="center">
<li> <a href="index.html">Overview</a> <li> <a href="index.html">Overview</a>
@ -128,21 +153,9 @@ for the JavaScript code in this tag.
<li> <a href="snippet-reference.html">Reference</a> <li> <a href="snippet-reference.html">Reference</a>
</ul> </ul>
</nav> </nav>
</div> </div>
<div id="content"> <div id="content">
<h1 class="title">Expanding snippets</h1> <h1 class="title">Expanding snippets</h1>
<p>
This section describes how YASnippet chooses snippets for expansion at point.
</p>
<p>
Maybe, you'll want some snippets to be expanded in a particular
mode, or only under certain conditions, or be prompted using
</p>
<div id="table-of-contents"> <div id="table-of-contents">
<h2>Table of Contents</h2> <h2>Table of Contents</h2>
<div id="text-table-of-contents"> <div id="text-table-of-contents">
@ -178,104 +191,109 @@ for the JavaScript code in this tag.
</ul> </ul>
</div> </div>
</div> </div>
<p>
This section describes how YASnippet chooses snippets for expansion at point.
</p>
<div id="outline-container-1" class="outline-2"> <p>
Maybe, you'll want some snippets to be expanded in a particular
mode, or only under certain conditions, or be prompted using
</p>
<div id="outline-container-sec-1" class="outline-2">
<h2 id="sec-1">Triggering expansion</h2> <h2 id="sec-1">Triggering expansion</h2>
<div class="outline-text-2" id="text-1"> <div class="outline-text-2" id="text-1">
<p> <p>
You can use YASnippet to expand snippets in different ways: You can use YASnippet to expand snippets in different ways:
</p> </p>
<ul>
<ul class="org-ul">
<li>When <a href="snippet-reference.html#yas-minor-mode"><code>yas-minor-mode</code></a> is active: <li>When <a href="snippet-reference.html#yas-minor-mode"><code>yas-minor-mode</code></a> is active:
<ul> <ul class="org-ul">
<li>Type the snippet's <b>trigger key</b> then calling <a href="snippet-reference.html#yas-expand"><code>yas-expand</code></a> <li>Type the snippet's <b>trigger key</b> then calling <a href="snippet-reference.html#yas-expand"><code>yas-expand</code></a>
(bound to <code>TAB</code> by default). (bound to <code>TAB</code> by default).
</li> </li>
<li>Use the snippet's <b>keybinding</b>. <li>Use the snippet's <b>keybinding</b>.
</li> </li>
<li>By expanding directly from the "YASnippet" menu in the menu-bar <li>By expanding directly from the "YASnippet" menu in the menu-bar
</li> </li>
<li>Using hippie-expand
<li>Using hippie-expand
</li> </li>
</ul> </ul>
</li> </li>
<li>Call <a href="snippet-reference.html#yas-insert-snippet"><code>yas-insert-snippet</code></a> (use <code>M-x yas-insert-snippet=</code> or its <li>Call <a href="snippet-reference.html#yas-insert-snippet"><code>yas-insert-snippet</code></a> (use <code>M-x yas-insert-snippet=</code> or its
keybinding <code>C-c &amp; C-s</code>). keybinding <code>C-c &amp; C-s</code>).
</li> </li>
<li>Use m2m's excellent auto-complete <li>Use m2m's excellent auto-complete
TODO: example for this TODO: example for this
</li> </li>
<li>Expanding from emacs-lisp code <li>Expanding from emacs-lisp code
</li> </li>
</ul> </ul>
</div> </div>
<div id="outline-container-1-1" class="outline-3"> <div id="outline-container-sec-1-1" class="outline-3">
<h3 id="sec-1-1">Trigger key</h3> <h3 id="sec-1-1">Trigger key</h3>
<div class="outline-text-3" id="text-1-1"> <div class="outline-text-3" id="text-1-1">
<p> <p>
<a href="snippet-reference.html#yas-expand"><code>yas-expand</code></a> tries to expand a <i>snippet abbrev</i> (also known as <a href="snippet-reference.html#yas-expand"><code>yas-expand</code></a> tries to expand a <i>snippet abbrev</i> (also known as
<i>snippet key</i>) before point. <i>snippet key</i>) before point.
</p> </p>
<p> <p>
When <a href="snippet-reference.html#yas-minor-mode"><code>yas-minor-mode</code></a> is enabled, it binds <a href="snippet-reference.html#yas-expand"><code>yas-expand</code></a> to <code>TAB</code> and When <a href="snippet-reference.html#yas-minor-mode"><code>yas-minor-mode</code></a> is enabled, it binds <a href="snippet-reference.html#yas-expand"><code>yas-expand</code></a> to <code>TAB</code> and
<code>&lt;tab&gt;</code> by default, however, you can freely set it to some other key: <code>&lt;tab&gt;</code> by default, however, you can freely set it to some other key:
</p> </p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(define-key yas-minor-mode-map (kbd "&lt;tab&gt;") nil)
<pre class="example">(define-key yas-minor-mode-map (kbd "&lt;tab&gt;") nil)
(define-key yas-minor-mode-map (kbd "TAB") nil) (define-key yas-minor-mode-map (kbd "TAB") nil)
(define-key yas-minor-mode-map (kbd "&lt;the new key&gt;") 'yas-expand) (define-key yas-minor-mode-map (kbd "&lt;the new key&gt;") 'yas-expand)
</pre> </pre>
</div>
<p> <p>
To enable the YASnippet minor mode in all buffers globally use the To enable the YASnippet minor mode in all buffers globally use the
command <a href="snippet-reference.html#yas-global-mode"><code>yas-global-mode</code></a>. This will enable a modeline indicator, command <a href="snippet-reference.html#yas-global-mode"><code>yas-global-mode</code></a>. This will enable a modeline indicator,
<code>yas</code>: <code>yas</code>:
</p> </p>
<p>
<img src="./images/minor-mode-indicator.png" alt="./images/minor-mode-indicator.png" />
<div class="figure">
<p><img src="./images/minor-mode-indicator.png" alt="minor-mode-indicator.png" />
</p> </p>
</div>
<p> <p>
When you use <a href="snippet-reference.html#yas-global-mode"><code>yas-global-mode</code></a> you can also selectively disable When you use <a href="snippet-reference.html#yas-global-mode"><code>yas-global-mode</code></a> you can also selectively disable
YASnippet in some buffers by setting the buffer-local variable YASnippet in some buffers by setting the buffer-local variable
<a href="snippet-reference.html#yas-dont-active"><code>yas-dont-active</code></a> in the buffer's mode hook. <a href="snippet-reference.html#yas-dont-active"><code>yas-dont-active</code></a> in the buffer's mode hook.
</p> </p>
</div> </div>
<div id="outline-container-1-1-1" class="outline-4"> <div id="outline-container-sec-1-1-1" class="outline-4">
<h4 id="sec-1-1-1">Fallback behaviour</h4> <h4 id="sec-1-1-1">Fallback behaviour</h4>
<div class="outline-text-4" id="text-1-1-1"> <div class="outline-text-4" id="text-1-1-1">
<p> <p>
<a href="snippet-reference.html#yas-fallback-behaviour"><code>yas-fallback-behaviour</code></a> is a customization variable bound to <a href="snippet-reference.html#yas-fallback-behaviour"><code>yas-fallback-behaviour</code></a> is a customization variable bound to
'<code>call-other-command</code> by default. If <a href="snippet-reference.html#yas-expand"><code>yas-expand</code></a> failed to find any '<code>call-other-command</code> by default. If <a href="snippet-reference.html#yas-expand"><code>yas-expand</code></a> failed to find any
suitable snippet to expand, it will disable the minor mode temporarily suitable snippet to expand, it will disable the minor mode temporarily
and find if there's any other command bound to the same key. and find if there's any other command bound to the same key.
</p> </p>
<p> <p>
If found, the command will be called. Usually this works very well If found, the command will be called. Usually this works very well
&ndash;when there's a snippet, expand it, otherwise, call whatever command &#x2013;when there's a snippet, expand it, otherwise, call whatever command
originally bind to the trigger key. originally bind to the trigger key.
</p> </p>
<p> <p>
However, you can change this behavior by customizing the However, you can change this behavior by customizing the
<a href="snippet-reference.html#yas-fallback-behavior"><code>yas-fallback-behavior</code></a> variable. If you set this variable to <a href="snippet-reference.html#yas-fallback-behavior"><code>yas-fallback-behavior</code></a> variable. If you set this variable to
@ -284,63 +302,53 @@ However, you can change this behavior by customizing the
</p> </p>
</div> </div>
</div> </div>
</div> </div>
<div id="outline-container-1-2" class="outline-3"> <div id="outline-container-sec-1-2" class="outline-3">
<h3 id="sec-1-2">Insert at point</h3> <h3 id="sec-1-2">Insert at point</h3>
<div class="outline-text-3" id="text-1-2"> <div class="outline-text-3" id="text-1-2">
<p> <p>
The command <a href="#yas-insert-snippet"><code>yas-insert-snippet</code></a> lets you insert snippets at point The command <i><code>yas-insert-snippet</code></i> lets you insert snippets at point
<i>for your current major mode</i>. It prompts you for the snippet key <i>for your current major mode</i>. It prompts you for the snippet key
first, and then for a snippet template if more than one template first, and then for a snippet template if more than one template
exists for the same key. exists for the same key.
</p> </p>
<p> <p>
The list presented contains the snippets that can be inserted at point, The list presented contains the snippets that can be inserted at point,
according to the condition system. If you want to see all applicable according to the condition system. If you want to see all applicable
snippets for the major mode, prefix this command with <code>C-u</code>. snippets for the major mode, prefix this command with <code>C-u</code>.
</p> </p>
<p> <p>
The prompting methods used are again controlled by The prompting methods used are again controlled by
<a href="snippet-reference.html#yas-prompt-functions"><code>yas-prompt-functions</code></a>. <a href="snippet-reference.html#yas-prompt-functions"><code>yas-prompt-functions</code></a>.
</p> </p>
</div> </div>
</div> </div>
<div id="outline-container-1-3" class="outline-3"> <div id="outline-container-sec-1-3" class="outline-3">
<h3 id="sec-1-3">Snippet keybinding</h3> <h3 id="sec-1-3">Snippet keybinding</h3>
<div class="outline-text-3" id="text-1-3"> <div class="outline-text-3" id="text-1-3">
<p> <p>
See the section of the <code># binding:</code> directive in See the section of the <code># binding:</code> directive in
<a href="./snippet-development.html">Writing Snippets</a>. <a href="./snippet-development.html">Writing Snippets</a>.
</p> </p>
</div> </div>
</div> </div>
<div id="outline-container-1-4" class="outline-3"> <div id="outline-container-sec-1-4" class="outline-3">
<h3 id="sec-1-4">Expanding from the menu</h3> <h3 id="sec-1-4">Expanding from the menu</h3>
<div class="outline-text-3" id="text-1-4"> <div class="outline-text-3" id="text-1-4">
<p> <p>
See <a href="./snippet-menu.html">the YASnippet Menu</a>. See <a href="./snippet-menu.html">the YASnippet Menu</a>.
</p> </p>
</div> </div>
</div> </div>
<div id="outline-container-1-5" class="outline-3"> <div id="outline-container-sec-1-5" class="outline-3">
<h3 id="sec-1-5">Expanding with <code>hippie-expand</code></h3> <h3 id="sec-1-5">Expanding with <code>hippie-expand</code></h3>
<div class="outline-text-3" id="text-1-5"> <div class="outline-text-3" id="text-1-5">
<p> <p>
To integrate with <code>hippie-expand</code>, just put To integrate with <code>hippie-expand</code>, just put
<a href="snippet-reference.html#yas-hippie-try-expand"><code>yas-hippie-try-expand</code></a> in <a href="snippet-reference.html#yas-hippie-try-expand"><code>yas-hippie-try-expand</code></a> in
@ -349,70 +357,65 @@ when placed at the top of the list, but it can be put anywhere you
prefer. prefer.
</p> </p>
</div> </div>
</div> </div>
<div id="outline-container-1-6" class="outline-3"> <div id="outline-container-sec-1-6" class="outline-3">
<h3 id="sec-1-6">Expanding from emacs-lisp code</h3> <h3 id="sec-1-6">Expanding from emacs-lisp code</h3>
<div class="outline-text-3" id="text-1-6"> <div class="outline-text-3" id="text-1-6">
<p> <p>
Sometimes you might want to expand a snippet directly from you own Sometimes you might want to expand a snippet directly from your own
elisp code. You should call elisp code. You should call <a href="snippet-reference.html#yas-expand-snippet"><code>yas-expand-snippet</code></a> instead of
<a href="snippet-reference.html#yas-expand-snippet"><code>yas-expand-snippet</code></a> instead of <a href="snippet-reference.html#yas-expand"><code>yas-expand</code></a> in this case. <a href="snippet-reference.html#yas-expand-snippet"><code>yas-expand-snippet</code></a> takes a string in
<a href="snippet-reference.html#yas-expand"><code>yas-expand</code></a> in this case. snippet template syntax, if you want to expand an existing snippet you
can use <a href="snippet-reference.html#yas-lookup-snippet"><code>yas-lookup-snippet</code></a> to find its contents by name.
</p> </p>
<p> <p>
As with expanding from the menubar, the condition system and multiple As with expanding from the menubar, the condition system and multiple
candidates doesn't affect expansion. In fact, expanding from the candidates doesn't affect expansion (the condition system does affect
YASnippet menu has the same effect of evaluating the follow code: <a href="snippet-reference.html#yas-lookup-snippet"><code>yas-lookup-snippet</code></a> though). In fact, expanding from the YASnippet
menu has the same effect of evaluating the follow code:
</p> </p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(yas-expand-snippet template)
<pre class="example">(yas-expand-snippet template)
</pre> </pre>
</div>
<p> <p>
See the internal documentation on <a href="snippet-reference.html#yas-expand-snippet"><code>yas-expand-snippet</code></a> for more See the internal documentation on <a href="snippet-reference.html#yas-expand-snippet"><code>yas-expand-snippet</code></a> and
information. <a href="snippet-reference.html#yas-lookup-snippet"><code>yas-lookup-snippet</code></a> for more information.
</p> </p>
</div> </div>
</div> </div>
</div> </div>
<div id="outline-container-2" class="outline-2"> <div id="outline-container-sec-2" class="outline-2">
<h2 id="sec-2">Controlling expansion</h2> <h2 id="sec-2">Controlling expansion</h2>
<div class="outline-text-2" id="text-2"> <div class="outline-text-2" id="text-2">
</div><div id="outline-container-sec-2-1" class="outline-3">
</div>
<div id="outline-container-2-1" class="outline-3">
<h3 id="sec-2-1">Eligible snippets</h3> <h3 id="sec-2-1">Eligible snippets</h3>
<div class="outline-text-3" id="text-2-1"> <div class="outline-text-3" id="text-2-1">
<p> <p>
YASnippet does quite a bit of filtering to find out which snippets are YASnippet does quite a bit of filtering to find out which snippets are
eligible for expanding at the current cursor position. eligible for expanding at the current cursor position.
</p> </p>
<p> <p>
In particular, the following things matter: In particular, the following things matter:
</p> </p>
<ul>
<ul class="org-ul">
<li>Currently loaded snippets tables <li>Currently loaded snippets tables
<p> <p>
These are loaded from a directory hierarchy in your file system. See These are loaded from a directory hierarchy in your file system. See
<a href="./snippet-organization.html">Organizing Snippets</a>. They are named <a href="./snippet-organization.html">Organizing Snippets</a>. They are named
after major modes like <code>html-mode</code>, <code>ruby-mode</code>, etc&hellip; after major modes like <code>html-mode</code>, <code>ruby-mode</code>, etc&#x2026;
</p> </p>
</li> </li>
<li>Major mode of the current buffer <li>Major mode of the current buffer
<p> <p>
@ -422,6 +425,7 @@ In particular, the following things matter:
mode you are in currently. mode you are in currently.
</p> </p>
</li> </li>
<li>Parent tables <li>Parent tables
<p> <p>
@ -430,28 +434,28 @@ In particular, the following things matter:
eligible tables are also considered. eligible tables are also considered.
</p> </p>
</li> </li>
<li>Buffer-local list of extra modes <li>Buffer-local list of extra modes
<p> <p>
Use <a href="#yas-activate-extra-mode"><code>yas-activate-extra-mode</code></a> to Use <i><code>yas-activate-extra-mode</code></i> to
consider snippet tables whose name does not correspond to a major consider snippet tables whose name does not correspond to a major
mode. Typically, you call this from a minor mode hook, for example: mode. Typically, you call this from a minor mode hook, for example:
</p></li> </p>
</li>
</ul> </ul>
<div class="org-src-container">
<pre class="src src-emacs-lisp">;; When entering rinari-minor-mode, consider also the snippets in the
<pre class="example">;; When entering rinari-minor-mode, consider also the snippets in the
;; snippet table "rails-mode" ;; snippet table "rails-mode"
(add-hook 'rinari-minor-mode-hook (add-hook 'rinari-minor-mode-hook
#'(lambda () #'(lambda ()
(yas-activate-extra-mode 'rails-mode))) (yas-activate-extra-mode 'rails-mode)))
</pre> </pre>
</div>
<ul class="org-ul">
<ul>
<li>Buffer-local <li>Buffer-local
<a href="snippet-reference.html#yas-buffer-local-condition"><code>yas-buffer-local-condition</code></a> <a href="snippet-reference.html#yas-buffer-local-condition"><code>yas-buffer-local-condition</code></a>
variable variable
@ -460,26 +464,23 @@ In particular, the following things matter:
This variable provides finer grained control over what snippets can This variable provides finer grained control over what snippets can
be expanded in the current buffer. The default value won't let you be expanded in the current buffer. The default value won't let you
expand snippets inside comments or string literals for example. See expand snippets inside comments or string literals for example. See
The condition system_ for more info. The condition system\_ for more info.
</p></li> </p>
</li>
</ul> </ul>
</div>
</div> </div>
</div> <div id="outline-container-sec-2-2" class="outline-3">
<div id="outline-container-2-2" class="outline-3">
<h3 id="sec-2-2">The condition system</h3> <h3 id="sec-2-2">The condition system</h3>
<div class="outline-text-3" id="text-2-2"> <div class="outline-text-3" id="text-2-2">
<p> <p>
Consider this scenario: you are an old Emacs hacker. You like the Consider this scenario: you are an old Emacs hacker. You like the
abbrev-way and bind <a href="snippet-reference.html#yas-expand"><code>yas-expand</code></a> to <code>SPC</code>. However, you don't want abbrev-way and bind <a href="snippet-reference.html#yas-expand"><code>yas-expand</code></a> to <code>SPC</code>. However, you don't want
<code>if</code> to be expanded as a snippet when you are typing in a comment <code>if</code> to be expanded as a snippet when you are typing in a comment
block or a string (e.g. in <code>python-mode</code>). block or a string (e.g. in <code>python-mode</code>).
</p> </p>
<p> <p>
If you use the <code># condition :</code> directive (see If you use the <code># condition :</code> directive (see
<a href="./snippet-development.html">Writing Snippets</a>) you could just specify <a href="./snippet-development.html">Writing Snippets</a>) you could just specify
@ -489,83 +490,85 @@ snippets is just boring. So has a buffer local variable
<a href="snippet-reference.html#yas-buffer-local-condition"><code>yas-buffer-local-condition</code></a>. You can set this variable to <a href="snippet-reference.html#yas-buffer-local-condition"><code>yas-buffer-local-condition</code></a>. You can set this variable to
<code>(not (python-in-string/comment))</code> in <code>python-mode-hook</code>. <code>(not (python-in-string/comment))</code> in <code>python-mode-hook</code>.
</p> </p>
<p> <p>
Then, what if you really want some particular snippet to expand even Then, what if you really want some particular snippet to expand even
inside a comment? Set <a href="snippet-reference.html#yas-buffer-local-condition"><code>yas-buffer-local-condition</code></a> like this inside a comment? Set <a href="snippet-reference.html#yas-buffer-local-condition"><code>yas-buffer-local-condition</code></a> like this
</p> </p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(add-hook 'python-mode-hook
<pre class="example">(add-hook 'python-mode-hook
(lambda () (lambda ()
(setq yas-buffer-local-condition (setq yas-buffer-local-condition
'(if (python-in-string/comment) '(if (python-in-string/comment)
'(require-snippet-condition . force-in-comment) '(require-snippet-condition . force-in-comment)
t)))) t))))
</pre> </pre>
</div>
<p> <p>
&hellip; and specify the condition for a snippet that you're going to expand &#x2026; and specify the condition for a snippet that you're going to expand
in comment to be evaluated to the symbol <code>force-in-comment</code>. Then it can in comment to be evaluated to the symbol <code>force-in-comment</code>. Then it can
be expanded as you expected, while other snippets like <code>if</code> still can't be expanded as you expected, while other snippets like <code>if</code> still can't
expanded in comment. expanded in comment.
</p> </p>
<p> <p>
For the full set of possible conditions, see the documentation for For the full set of possible conditions, see the documentation for
<a href="snippet-reference.html#yas-buffer-local-condition"><code>yas-buffer-local-condition</code></a>. <a href="snippet-reference.html#yas-buffer-local-condition"><code>yas-buffer-local-condition</code></a>.
</p> </p>
</div> </div>
</div> </div>
<div id="outline-container-2-3" class="outline-3"> <div id="outline-container-sec-2-3" class="outline-3">
<h3 id="sec-2-3">Multiples snippet with the same key</h3> <h3 id="sec-2-3">Multiples snippet with the same key</h3>
<div class="outline-text-3" id="text-2-3"> <div class="outline-text-3" id="text-2-3">
<p> <p>
The rules outlined <a href="#sec-2-1">above</a> can return more than The rules outlined <i>above</i> can return more than
one snippet to be expanded at point. one snippet to be expanded at point.
</p> </p>
<p> <p>
When there are multiple candidates, YASnippet will let you select one. When there are multiple candidates, YASnippet will let you select one.
The UI for selecting multiple candidate can be customized through The UI for selecting multiple candidate can be customized through
<a href="snippet-reference.html#yas-prompt-functions"><code>yas-prompt-functions</code></a> , which defines your preferred methods of being <a href="snippet-reference.html#yas-prompt-functions"><code>yas-prompt-functions</code></a> , which defines your preferred methods of being
prompted for snippets. prompted for snippets.
</p> </p>
<p> <p>
You can customize it with You can customize it with
<code>M-x customize-variable RET yas-prompt-functions RET</code>. Alternatively you <code>M-x customize-variable RET yas-prompt-functions RET</code>. Alternatively you
can put in your emacs-file: can put in your emacs-file:
</p> </p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(setq yas-prompt-functions '(yas-x-prompt yas-dropdown-prompt))
<pre class="example">(setq yas-prompt-functions '(yas-x-prompt yas-dropdown-prompt))
</pre> </pre>
</div>
<p> <p>
Currently there are some alternatives solution with YASnippet. Currently there are some alternatives solution with YASnippet.
</p> </p>
</div> </div>
<div id="outline-container-2-3-1" class="outline-4"> <div id="outline-container-sec-2-3-1" class="outline-4">
<h4 id="sec-2-3-1">Use the X window system</h4> <h4 id="sec-2-3-1">Use the X window system</h4>
<div class="outline-text-4" id="text-2-3-1"> <div class="outline-text-4" id="text-2-3-1">
<div class="figure">
<p> <p><img src="./images/x-menu.png" alt="x-menu.png" />
<img src="./images/x-menu.png" alt="./images/x-menu.png" />
</p> </p>
</div>
<p> <p>
The function <a href="snippet-reference.html#yas-x-prompt"><code>yas-x-prompt</code></a> can be used to show a popup menu for you to The function <a href="snippet-reference.html#yas-x-prompt"><code>yas-x-prompt</code></a> can be used to show a popup menu for you to
select. This menu will be part of you native window system widget, which select. This menu will be part of you native window system widget, which
means: means:
</p> </p>
<ul>
<ul class="org-ul">
<li>It usually looks beautiful. E.g. when you compile Emacs with gtk <li>It usually looks beautiful. E.g. when you compile Emacs with gtk
support, this menu will be rendered with your gtk theme. support, this menu will be rendered with your gtk theme.
</li> </li>
@ -575,68 +578,63 @@ means:
<li>This function can't be used when in a terminal. <li>This function can't be used when in a terminal.
</li> </li>
</ul> </ul>
</div>
</div> </div>
</div> <div id="outline-container-sec-2-3-2" class="outline-4">
<div id="outline-container-2-3-2" class="outline-4">
<h4 id="sec-2-3-2">Minibuffer prompting</h4> <h4 id="sec-2-3-2">Minibuffer prompting</h4>
<div class="outline-text-4" id="text-2-3-2"> <div class="outline-text-4" id="text-2-3-2">
<div class="figure">
<p> <p><img src="./images/ido-menu.png" alt="ido-menu.png" />
<img src="./images/ido-menu.png" alt="./images/ido-menu.png" />
</p> </p>
</div>
<p> <p>
You can use functions <a href="snippet-reference.html#yas-completing-prompt"><code>yas-completing-prompt</code></a> for the classic emacs You can use functions <a href="snippet-reference.html#yas-completing-prompt"><code>yas-completing-prompt</code></a> for the classic emacs
completion method or <a href="snippet-reference.html#yas-ido-prompt"><code>yas-ido-prompt</code></a> for a much nicer looking method. completion method or <a href="snippet-reference.html#yas-ido-prompt"><code>yas-ido-prompt</code></a> for a much nicer looking method.
The best way is to try it. This works in a terminal. The best way is to try it. This works in a terminal.
</p> </p>
</div> </div>
</div> </div>
<div id="outline-container-2-3-3" class="outline-4"> <div id="outline-container-sec-2-3-3" class="outline-4">
<h4 id="sec-2-3-3">Use <code>dropdown-menu.el</code></h4> <h4 id="sec-2-3-3">Use <code>dropdown-menu.el</code></h4>
<div class="outline-text-4" id="text-2-3-3"> <div class="outline-text-4" id="text-2-3-3">
<div class="figure">
<p> <p><img src="./images/dropdown-menu.png" alt="dropdown-menu.png" />
<img src="./images/dropdown-menu.png" alt="./images/dropdown-menu.png" />
</p> </p>
</div>
<p> <p>
The function <a href="snippet-reference.html#yas-dropdown-prompt"><code>yas-dropdown-prompt</code></a> can also be placed in the The function <a href="snippet-reference.html#yas-dropdown-prompt"><code>yas-dropdown-prompt</code></a> can also be placed in the
<a href="snippet-reference.html#yas-prompt-functions"><code>yas-prompt-functions</code></a> list. <a href="snippet-reference.html#yas-prompt-functions"><code>yas-prompt-functions</code></a> list.
</p> </p>
<p> <p>
This works in both window system and terminal and is customizable, you This works in both window system and terminal and is customizable, you
can use <code>C-n</code>, <code>C-p</code> to navigate, <code>q</code> to quit and even press <code>6</code> as a can use <code>C-n</code>, <code>C-p</code> to navigate, <code>q</code> to quit and even press <code>6</code> as a
shortcut to select the 6th candidate. shortcut to select the 6th candidate.
</p> </p>
</div> </div>
</div> </div>
<div id="outline-container-2-3-4" class="outline-4"> <div id="outline-container-sec-2-3-4" class="outline-4">
<h4 id="sec-2-3-4">Roll your own</h4> <h4 id="sec-2-3-4">Roll your own</h4>
<div class="outline-text-4" id="text-2-3-4"> <div class="outline-text-4" id="text-2-3-4">
<p> <p>
See the documentation on variable <a href="snippet-reference.html#yas-prompt-functions"><code>yas-prompt-functions</code></a> See the documentation on variable <a href="snippet-reference.html#yas-prompt-functions"><code>yas-prompt-functions</code></a>
</p></div>
</div>
</div>
</div>
</div>
<div id="postamble">
<hr><p class='creator'>Generated by <a href="http://orgmode.org">Org</a> version 7.9.3f with <a href="http://www.gnu.org/software/emacs/">Emacs</a> version 24 on 2014-10-01T21:16+0100 from 08b044e559cc350c6e7142d088ec2d4a82e378cb
</p> </p>
<p class='xhtml-validation'><a href="http://validator.w3.org/check?uri=referer">Validate XHTML 1.0</a></p> </div>
</div>
</div>
</div>
</div>
<div id="postamble" class="status">
<hr><p class='creator'>Generated by <a href="http://www.gnu.org/software/emacs/">Emacs</a> 24.4.91.1 (<a href="http://orgmode.org">Org</a> mode 8.2.10) on from 7703a55ac416a131dec45fa6a1e0ec1e31adf760
</p>
<p class='xhtml-validation'><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
</div> </div>
</body> </body>
</html> </html>

View File

@ -1,39 +1,61 @@
<?xml version="1.0" encoding="iso-8859-1"?> <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head> <head>
<title>YASnippet menu</title> <title>YASnippet menu</title>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"/> <!-- 2015-09-24 Thu 21:14 -->
<meta name="title" content="YASnippet menu"/> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="generator" content="Org-mode" /> <meta name="generator" content="Org-mode" />
<meta name="generated" content="2014-10-01T21:16+0100"/>
<meta name="author" content=""/>
<meta name="description" content=""/>
<meta name="keywords" content=""/>
<style type="text/css"> <style type="text/css">
<!--/*--><![CDATA[/*><!--*/ <!--/*--><![CDATA[/*><!--*/
html { font-family: Times, serif; font-size: 12pt; }
.title { text-align: center; } .title { text-align: center; }
.todo { color: red; } .todo { font-family: monospace; color: red; }
.done { color: green; } .done { color: green; }
.tag { background-color: #add8e6; font-weight:normal } .tag { background-color: #eee; font-family: monospace;
.target { } padding: 2px; font-size: 80%; font-weight: normal; }
.timestamp { color: #bebebe; } .timestamp { color: #bebebe; }
.timestamp-kwd { color: #5f9ea0; } .timestamp-kwd { color: #5f9ea0; }
.right { margin-left: auto; margin-right: 0px; text-align: right; } .right { margin-left: auto; margin-right: 0px; text-align: right; }
.left { margin-left: 0px; margin-right: auto; text-align: left; } .left { margin-left: 0px; margin-right: auto; text-align: left; }
.center { margin-left: auto; margin-right: auto; text-align: center; } .center { margin-left: auto; margin-right: auto; text-align: center; }
p.verse { margin-left: 3% } .underline { text-decoration: underline; }
#postamble p, #preamble p { font-size: 90%; margin: .2em; }
p.verse { margin-left: 3%; }
pre { pre {
border: 1pt solid #AEBDCC; border: 1px solid #ccc;
background-color: #F3F5F7; box-shadow: 3px 3px 3px #eee;
padding: 5pt; padding: 8pt;
font-family: courier, monospace; font-family: monospace;
font-size: 90%;
overflow: auto; overflow: auto;
margin: 1.2em;
} }
pre.src {
position: relative;
overflow: visible;
padding-top: 1.2em;
}
pre.src:before {
display: none;
position: absolute;
background-color: white;
top: -10px;
right: 10px;
padding: 3px;
border: 1px solid black;
}
pre.src:hover:before { display: inline;}
pre.src-sh:before { content: 'sh'; }
pre.src-bash:before { content: 'sh'; }
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
pre.src-R:before { content: 'R'; }
pre.src-perl:before { content: 'Perl'; }
pre.src-java:before { content: 'Java'; }
pre.src-sql:before { content: 'SQL'; }
table { border-collapse:collapse; } table { border-collapse:collapse; }
caption.t-above { caption-side: top; }
caption.t-bottom { caption-side: bottom; }
td, th { vertical-align:top; } td, th { vertical-align:top; }
th.right { text-align: center; } th.right { text-align: center; }
th.left { text-align: center; } th.left { text-align: center; }
@ -42,22 +64,27 @@
td.left { text-align: left; } td.left { text-align: left; }
td.center { text-align: center; } td.center { text-align: center; }
dt { font-weight: bold; } dt { font-weight: bold; }
div.figure { padding: 0.5em; } .footpara:nth-child(2) { display: inline; }
div.figure p { text-align: center; } .footpara { display: block; }
div.inlinetask { .footdef { margin-bottom: 1em; }
.figure { padding: 1em; }
.figure p { text-align: center; }
.inlinetask {
padding: 10px; padding: 10px;
border: 2px solid gray; border: 2px solid gray;
margin: 10px; margin: 10px;
background: #ffffcc; background: #ffffcc;
} }
#org-div-home-and-up
{ text-align: right; font-size: 70%; white-space: nowrap; }
textarea { overflow-x: auto; } textarea { overflow-x: auto; }
.linenr { font-size: smaller } .linenr { font-size: smaller }
.code-highlighted { background-color: #ffff00; } .code-highlighted { background-color: #ffff00; }
.org-info-js_info-navigation { border-style: none; } .org-info-js_info-navigation { border-style: none; }
#org-info-js_console-label { font-size:10px; font-weight:bold; #org-info-js_console-label
white-space:nowrap; } { font-size: 10px; font-weight: bold; white-space: nowrap; }
.org-info-js_search-highlight {background-color:#ffff00; color:#000000; .org-info-js_search-highlight
font-weight:bold; } { background-color: #ffff00; color: #000000; font-weight: bold; }
/*]]>*/--> /*]]>*/-->
</style> </style>
<link rel="stylesheet" type="text/css" href="stylesheets/manual.css" /> <link rel="stylesheet" type="text/css" href="stylesheets/manual.css" />
@ -107,11 +134,9 @@ for the JavaScript code in this tag.
} }
/*]]>*///--> /*]]>*///-->
</script> </script>
</head> </head>
<body> <body>
<div id="preamble" class="status">
<div id="preamble">
<nav> <nav>
<ul class="center"> <ul class="center">
<li> <a href="index.html">Overview</a> <li> <a href="index.html">Overview</a>
@ -128,40 +153,9 @@ for the JavaScript code in this tag.
<li> <a href="snippet-reference.html">Reference</a> <li> <a href="snippet-reference.html">Reference</a>
</ul> </ul>
</nav> </nav>
</div> </div>
<div id="content"> <div id="content">
<h1 class="title">YASnippet menu</h1> <h1 class="title">YASnippet menu</h1>
<p>
When <a href="snippet-reference.html#yas-minor-mode"><code>yas-minor-mode</code></a> is active, YASnippet will setup a menu just after
the "Buffers" menu in the menubar.
</p>
<p>
In this menu, you can find
</p>
<ul>
<li>The currently loaded snippet definitions, organized by major mode,
and optional grouping.
</li>
<li>A rundown of the most common commands, (followed by their
keybindings) including commands to load directories and reload all
snippet definitions.
</li>
<li>A series of submenus for customizing and exploring YASnippet
behavior.
</li>
</ul>
<p>
<img src="./images/menu-1.png" alt="./images/menu-1.png" />
</p>
<div id="table-of-contents"> <div id="table-of-contents">
<h2>Table of Contents</h2> <h2>Table of Contents</h2>
<div id="text-table-of-contents"> <div id="text-table-of-contents">
@ -174,105 +168,125 @@ In this menu, you can find
</ul> </ul>
</div> </div>
</div> </div>
<p>
When <a href="snippet-reference.html#yas-minor-mode"><code>yas-minor-mode</code></a> is active, YASnippet will setup a menu just after
the "Buffers" menu in the menubar.
</p>
<div id="outline-container-1" class="outline-2"> <p>
In this menu, you can find
</p>
<ul class="org-ul">
<li>The currently loaded snippet definitions, organized by major mode,
and optional grouping.
</li>
<li>A rundown of the most common commands, (followed by their
keybindings) including commands to load directories and reload all
snippet definitions.
</li>
<li>A series of submenus for customizing and exploring YASnippet
behavior.
</li>
</ul>
<div class="figure">
<p><img src="./images/menu-1.png" alt="menu-1.png" />
</p>
</div>
<div id="outline-container-sec-1" class="outline-2">
<h2 id="sec-1">Loading snippets from menu</h2> <h2 id="sec-1">Loading snippets from menu</h2>
<div class="outline-text-2" id="text-1"> <div class="outline-text-2" id="text-1">
<p> <p>
Invoking "Load snippets&hellip;" from the menu invokes <a href="snippet-reference.html#yas-load-directory"><code>yas-load-directory</code></a> Invoking "Load snippets&#x2026;" from the menu invokes <a href="snippet-reference.html#yas-load-directory"><code>yas-load-directory</code></a>
and prompts you for a snippet directory hierarchy to load. and prompts you for a snippet directory hierarchy to load.
</p> </p>
<p> <p>
Also useful is the "Reload everything" item to invoke <a href="#yas-reload-all"><code>yas-reload-all</code></a> Also useful is the "Reload everything" item to invoke <i><code>yas-reload-all</code></i>
which uncondionally reloads all the snippets directories defined in which uncondionally reloads all the snippets directories defined in
<a href="snippet-reference.html#yas-snippet-dirs"><code>yas-snippet-dirs</code></a> and rebuilds the menus. <a href="snippet-reference.html#yas-snippet-dirs"><code>yas-snippet-dirs</code></a> and rebuilds the menus.
</p> </p>
</div> </div>
</div> </div>
<div id="outline-container-2" class="outline-2"> <div id="outline-container-sec-2" class="outline-2">
<h2 id="sec-2">Snippet menu behavior</h2> <h2 id="sec-2">Snippet menu behavior</h2>
<div class="outline-text-2" id="text-2"> <div class="outline-text-2" id="text-2">
<p> <p>
YASnippet will list in this section all the loaded snippet definitions YASnippet will list in this section all the loaded snippet definitions
organized by snippet table name. organized by snippet table name.
</p> </p>
<p> <p>
You can use this section to explore currently loaded snippets. If you You can use this section to explore currently loaded snippets. If you
click on one of them, the default behavior is to expand it, click on one of them, the default behavior is to expand it,
unconditionally, inside the current buffer. unconditionally, inside the current buffer.
</p> </p>
<p> <p>
You can however, customize variable <a href="snippet-reference.html#yas-visit-from-menu"><code>yas-visit-from-menu</code></a> to be <code>t</code> You can however, customize variable <a href="snippet-reference.html#yas-visit-from-menu"><code>yas-visit-from-menu</code></a> to be <code>t</code>
which will take you to the snippet definition file when you select it which will take you to the snippet definition file when you select it
from the menu. from the menu.
</p> </p>
<p> <p>
If you want the menu show only snippet tables whose name corresponds to If you want the menu show only snippet tables whose name corresponds to
a "real" major mode. You do this by setting <a href="snippet-reference.html#yas-use-menu"><code>yas-use-menu</code></a> to a "real" major mode. You do this by setting <a href="snippet-reference.html#yas-use-menu"><code>yas-use-menu</code></a> to
'<code>real-modes</code>. '<code>real-modes</code>.
</p> </p>
<p> <p>
Finally, to have the menu show only the tables for the currently active Finally, to have the menu show only the tables for the currently active
mode, set <a href="snippet-reference.html#yas-use-menu"><code>yas-use-menu</code></a> to <code>abbreviate</code>. mode, set <a href="snippet-reference.html#yas-use-menu"><code>yas-use-menu</code></a> to <code>abbreviate</code>.
</p> </p>
<p> <p>
These customizations can also be found in the menu itself, under the These customizations can also be found in the menu itself, under the
"Snippet menu behavior" submenu. "Snippet menu behavior" submenu.
</p> </p>
</div> </div>
</div> </div>
<div id="outline-container-3" class="outline-2"> <div id="outline-container-sec-3" class="outline-2">
<h2 id="sec-3">Controlling indenting</h2> <h2 id="sec-3">Controlling indenting</h2>
<div class="outline-text-2" id="text-3"> <div class="outline-text-2" id="text-3">
<p> <p>
The "Indenting" submenu contains options to control the values of The "Indenting" submenu contains options to control the values of
<a href="snippet-reference.html#yas-indent-line"><code>yas-indent-line</code></a> and <a href="snippet-reference.html#yas-also-auto-indent-first-line"><code>yas-also-auto-indent-first-line</code></a>. See <a href="snippet-reference.html#yas-indent-line"><code>yas-indent-line</code></a> and <a href="snippet-reference.html#yas-also-auto-indent-first-line"><code>yas-also-auto-indent-first-line</code></a>. See
<a href="./snippet-development.html">Writing snippets</a>. <a href="./snippet-development.html">Writing snippets</a>.
</p> </p>
</div> </div>
</div> </div>
<div id="outline-container-4" class="outline-2"> <div id="outline-container-sec-4" class="outline-2">
<h2 id="sec-4">Prompting method</h2> <h2 id="sec-4">Prompting method</h2>
<div class="outline-text-2" id="text-4"> <div class="outline-text-2" id="text-4">
<p> <p>
The "Prompting method" submenu contains options to control the value of The "Prompting method" submenu contains options to control the value of
<a href="snippet-reference.html#yas-prompt-functions"><code>yas-prompt-functions</code></a>. See <a href="./snippet-expansion.html">Expanding snippets</a>. <a href="snippet-reference.html#yas-prompt-functions"><code>yas-prompt-functions</code></a>. See <a href="./snippet-expansion.html">Expanding snippets</a>.
</p> </p>
</div> </div>
</div> </div>
<div id="outline-container-5" class="outline-2"> <div id="outline-container-sec-5" class="outline-2">
<h2 id="sec-5">Misc</h2> <h2 id="sec-5">Misc</h2>
<div class="outline-text-2" id="text-5"> <div class="outline-text-2" id="text-5">
<p> <p>
The "Misc" submenu contains options to control the values of more The "Misc" submenu contains options to control the values of more
variables. variables.
</p></div>
</div>
</div>
<div id="postamble">
<hr><p class='creator'>Generated by <a href="http://orgmode.org">Org</a> version 7.9.3f with <a href="http://www.gnu.org/software/emacs/">Emacs</a> version 24 on 2014-10-01T21:16+0100 from 08b044e559cc350c6e7142d088ec2d4a82e378cb
</p> </p>
<p class='xhtml-validation'><a href="http://validator.w3.org/check?uri=referer">Validate XHTML 1.0</a></p> </div>
</div>
</div>
<div id="postamble" class="status">
<hr><p class='creator'>Generated by <a href="http://www.gnu.org/software/emacs/">Emacs</a> 24.4.91.1 (<a href="http://orgmode.org">Org</a> mode 8.2.10) on from 7703a55ac416a131dec45fa6a1e0ec1e31adf760
</p>
<p class='xhtml-validation'><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
</div> </div>
</body> </body>
</html> </html>

View File

@ -1,39 +1,61 @@
<?xml version="1.0" encoding="iso-8859-1"?> <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head> <head>
<title>Organizing snippets</title> <title>Organizing snippets</title>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"/> <!-- 2015-09-24 Thu 21:14 -->
<meta name="title" content="Organizing snippets"/> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="generator" content="Org-mode" /> <meta name="generator" content="Org-mode" />
<meta name="generated" content="2014-10-01T21:16+0100"/>
<meta name="author" content=""/>
<meta name="description" content=""/>
<meta name="keywords" content=""/>
<style type="text/css"> <style type="text/css">
<!--/*--><![CDATA[/*><!--*/ <!--/*--><![CDATA[/*><!--*/
html { font-family: Times, serif; font-size: 12pt; }
.title { text-align: center; } .title { text-align: center; }
.todo { color: red; } .todo { font-family: monospace; color: red; }
.done { color: green; } .done { color: green; }
.tag { background-color: #add8e6; font-weight:normal } .tag { background-color: #eee; font-family: monospace;
.target { } padding: 2px; font-size: 80%; font-weight: normal; }
.timestamp { color: #bebebe; } .timestamp { color: #bebebe; }
.timestamp-kwd { color: #5f9ea0; } .timestamp-kwd { color: #5f9ea0; }
.right { margin-left: auto; margin-right: 0px; text-align: right; } .right { margin-left: auto; margin-right: 0px; text-align: right; }
.left { margin-left: 0px; margin-right: auto; text-align: left; } .left { margin-left: 0px; margin-right: auto; text-align: left; }
.center { margin-left: auto; margin-right: auto; text-align: center; } .center { margin-left: auto; margin-right: auto; text-align: center; }
p.verse { margin-left: 3% } .underline { text-decoration: underline; }
#postamble p, #preamble p { font-size: 90%; margin: .2em; }
p.verse { margin-left: 3%; }
pre { pre {
border: 1pt solid #AEBDCC; border: 1px solid #ccc;
background-color: #F3F5F7; box-shadow: 3px 3px 3px #eee;
padding: 5pt; padding: 8pt;
font-family: courier, monospace; font-family: monospace;
font-size: 90%;
overflow: auto; overflow: auto;
margin: 1.2em;
} }
pre.src {
position: relative;
overflow: visible;
padding-top: 1.2em;
}
pre.src:before {
display: none;
position: absolute;
background-color: white;
top: -10px;
right: 10px;
padding: 3px;
border: 1px solid black;
}
pre.src:hover:before { display: inline;}
pre.src-sh:before { content: 'sh'; }
pre.src-bash:before { content: 'sh'; }
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
pre.src-R:before { content: 'R'; }
pre.src-perl:before { content: 'Perl'; }
pre.src-java:before { content: 'Java'; }
pre.src-sql:before { content: 'SQL'; }
table { border-collapse:collapse; } table { border-collapse:collapse; }
caption.t-above { caption-side: top; }
caption.t-bottom { caption-side: bottom; }
td, th { vertical-align:top; } td, th { vertical-align:top; }
th.right { text-align: center; } th.right { text-align: center; }
th.left { text-align: center; } th.left { text-align: center; }
@ -42,22 +64,27 @@
td.left { text-align: left; } td.left { text-align: left; }
td.center { text-align: center; } td.center { text-align: center; }
dt { font-weight: bold; } dt { font-weight: bold; }
div.figure { padding: 0.5em; } .footpara:nth-child(2) { display: inline; }
div.figure p { text-align: center; } .footpara { display: block; }
div.inlinetask { .footdef { margin-bottom: 1em; }
.figure { padding: 1em; }
.figure p { text-align: center; }
.inlinetask {
padding: 10px; padding: 10px;
border: 2px solid gray; border: 2px solid gray;
margin: 10px; margin: 10px;
background: #ffffcc; background: #ffffcc;
} }
#org-div-home-and-up
{ text-align: right; font-size: 70%; white-space: nowrap; }
textarea { overflow-x: auto; } textarea { overflow-x: auto; }
.linenr { font-size: smaller } .linenr { font-size: smaller }
.code-highlighted { background-color: #ffff00; } .code-highlighted { background-color: #ffff00; }
.org-info-js_info-navigation { border-style: none; } .org-info-js_info-navigation { border-style: none; }
#org-info-js_console-label { font-size:10px; font-weight:bold; #org-info-js_console-label
white-space:nowrap; } { font-size: 10px; font-weight: bold; white-space: nowrap; }
.org-info-js_search-highlight {background-color:#ffff00; color:#000000; .org-info-js_search-highlight
font-weight:bold; } { background-color: #ffff00; color: #000000; font-weight: bold; }
/*]]>*/--> /*]]>*/-->
</style> </style>
<link rel="stylesheet" type="text/css" href="stylesheets/manual.css" /> <link rel="stylesheet" type="text/css" href="stylesheets/manual.css" />
@ -107,11 +134,9 @@ for the JavaScript code in this tag.
} }
/*]]>*///--> /*]]>*///-->
</script> </script>
</head> </head>
<body> <body>
<div id="preamble" class="status">
<div id="preamble">
<nav> <nav>
<ul class="center"> <ul class="center">
<li> <a href="index.html">Overview</a> <li> <a href="index.html">Overview</a>
@ -128,14 +153,9 @@ for the JavaScript code in this tag.
<li> <a href="snippet-reference.html">Reference</a> <li> <a href="snippet-reference.html">Reference</a>
</ul> </ul>
</nav> </nav>
</div> </div>
<div id="content"> <div id="content">
<h1 class="title">Organizing snippets</h1> <h1 class="title">Organizing snippets</h1>
<div id="table-of-contents"> <div id="table-of-contents">
<h2>Table of Contents</h2> <h2>Table of Contents</h2>
<div id="text-table-of-contents"> <div id="text-table-of-contents">
@ -143,39 +163,32 @@ for the JavaScript code in this tag.
<li><a href="#sec-1">Basic structure</a></li> <li><a href="#sec-1">Basic structure</a></li>
<li><a href="#sec-2">Setting up <code>yas-snippet-dirs</code></a></li> <li><a href="#sec-2">Setting up <code>yas-snippet-dirs</code></a></li>
<li><a href="#sec-3">The <code>.yas-parents</code> file</a></li> <li><a href="#sec-3">The <code>.yas-parents</code> file</a></li>
<li><a href="#sec-4">The <code>.yas-make-groups</code> file</a></li> <li><a href="#sec-4"><span class="todo TODO">TODO</span> The <code>.yas-make-groups</code> file</a></li>
<li><a href="#sec-5">The <code>.yas-setup.el</code> file</a> <li><a href="#sec-5"><span class="todo TODO">TODO</span> The <code>.yas-setup.el</code> file</a>
<ul> <ul>
<li><a href="#sec-5-1"></a></li> <li><a href="#sec-5-1"><span class="todo TODO">TODO</span> </a></li>
</ul>
</li>
<li><a href="#sec-6">The <code>.yas-compiled-snippet.el</code> file</a>
<ul>
<li><a href="#sec-6-1"></a></li>
</ul> </ul>
</li> </li>
<li><a href="#sec-6">The <code>.yas-compiled-snippet.el</code> file</a></li>
<li><a href="#sec-7">The <code>.yas-skip</code> file</a> <li><a href="#sec-7">The <code>.yas-skip</code> file</a>
<ul> <ul>
<li><a href="#sec-7-1"></a></li> <li><a href="#sec-7-1"><span class="todo TODO">TODO</span> </a></li>
</ul> </ul>
</li> </li>
</ul> </ul>
</div> </div>
</div> </div>
<div id="outline-container-1" class="outline-2"> <div id="outline-container-sec-1" class="outline-2">
<h2 id="sec-1">Basic structure</h2> <h2 id="sec-1">Basic structure</h2>
<div class="outline-text-2" id="text-1"> <div class="outline-text-2" id="text-1">
<p> <p>
Snippet collections can be stored in plain text files. They are arranged by Snippet collections can be stored in plain text files. They are arranged by
sub-directories naming <b>snippet tables</b>. These mostly name Emacs major names. sub-directories naming <b>snippet tables</b>. These mostly name Emacs major names.
</p> </p>
<pre class="example">
.
<pre class="example">.
|-- c-mode |-- c-mode
| `-- printf | `-- printf
|-- java-mode |-- java-mode
@ -185,46 +198,43 @@ for the JavaScript code in this tag.
`-- time `-- time
</pre> </pre>
<p> <p>
The collections are loaded into <b>snippet tables</b> which the The collections are loaded into <b>snippet tables</b> which the
triggering mechanism (see <a href="snippet-expansion.html">Expanding Snippets</a>) looks up and triggering mechanism (see <a href="snippet-expansion.html">Expanding Snippets</a>) looks up and
(hopefully) causes the right snippet to be expanded for you. (hopefully) causes the right snippet to be expanded for you.
</p> </p>
</div> </div>
</div> </div>
<div id="outline-container-2" class="outline-2"> <div id="outline-container-sec-2" class="outline-2">
<h2 id="sec-2">Setting up <code>yas-snippet-dirs</code></h2> <h2 id="sec-2">Setting up <code>yas-snippet-dirs</code></h2>
<div class="outline-text-2" id="text-2"> <div class="outline-text-2" id="text-2">
<p> <p>
The emacs variable <a href="snippet-reference.html#yas-snippet-dirs"><code>yas-snippet-dirs</code></a> tells YASnippet The emacs variable <a href="snippet-reference.html#yas-snippet-dirs"><code>yas-snippet-dirs</code></a> tells YASnippet
which collections to consider. It's used when you activate which collections to consider. It's used when you activate
<a href="snippet-reference.html#yas-global-mode"><code>yas-global-mode</code></a> or call <a href="snippet-reference.html#yas-global-mode"><code>yas-global-mode</code></a> or call
<a href="snippet-reference.html#yas-reload-all"><code>yas-reload-all</code></a> interactively. <a href="snippet-reference.html#yas-reload-all"><code>yas-reload-all</code></a> interactively.
</p> </p>
<p> <p>
The default considers: The default considers:
</p> </p>
<ul>
<ul class="org-ul">
<li>a personal collection that lives in <code>~/.emacs.d/snippets</code> <li>a personal collection that lives in <code>~/.emacs.d/snippets</code>
</li> </li>
<li>the bundled collection, taken as a relative path to <code>yasnippet.el</code> localtion <li>the bundled collection, taken as a relative path to <code>yasnippet.el</code> localtion
</li> </li>
</ul> </ul>
<p> <p>
When you come across other snippet collections, do the following to try them When you come across other snippet collections, do the following to try them
out: out:
</p> </p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">;; Develop in ~/emacs.d/mysnippets, but also
<pre class="example">;; Develop in ~/emacs.d/mysnippets, but also
;; try out snippets in ~/Downloads/interesting-snippets ;; try out snippets in ~/Downloads/interesting-snippets
(setq yas-snippet-dirs '("~/emacs.d/mysnippets" (setq yas-snippet-dirs '("~/emacs.d/mysnippets"
"~/Downloads/interesting-snippets")) "~/Downloads/interesting-snippets"))
@ -233,22 +243,19 @@ for the JavaScript code in this tag.
(setq yas-snippet-dirs (append yas-snippet-dirs (setq yas-snippet-dirs (append yas-snippet-dirs
'("~/Downloads/interesting-snippets"))) '("~/Downloads/interesting-snippets")))
</pre> </pre>
</div>
<p> <p>
Collections appearing earlier in the list shadow snippets with same names Collections appearing earlier in the list override snippets with same names
appearing in collections later in the list. <a href="snippet-reference.html#yas-new-snippet"><code>yas-new-snippet</code></a> always stores appearing in collections later in the list. <a href="snippet-reference.html#yas-new-snippet"><code>yas-new-snippet</code></a> always stores
snippets in the first collection. snippets in the first collection.
</p> </p>
</div> </div>
</div> </div>
<div id="outline-container-3" class="outline-2"> <div id="outline-container-sec-3" class="outline-2">
<h2 id="sec-3">The <code>.yas-parents</code> file</h2> <h2 id="sec-3">The <code>.yas-parents</code> file</h2>
<div class="outline-text-2" id="text-3"> <div class="outline-text-2" id="text-3">
<p> <p>
It's very useful to have certain modes share snippets between It's very useful to have certain modes share snippets between
themselves. To do this, choose a mode subdirectory and place a themselves. To do this, choose a mode subdirectory and place a
@ -257,9 +264,8 @@ for the JavaScript code in this tag.
mode. mode.
</p> </p>
<pre class="example">
.
<pre class="example">.
|-- c-mode |-- c-mode
| |-- .yas-parents # contains "cc-mode text-mode" | |-- .yas-parents # contains "cc-mode text-mode"
| `-- printf | `-- printf
@ -273,35 +279,33 @@ for the JavaScript code in this tag.
|-- email |-- email
`-- time `-- time
</pre> </pre>
</div>
</div> </div>
</div>
<div id="outline-container-4" class="outline-2"> <div id="outline-container-sec-4" class="outline-2">
<h2 id="sec-4"><span class="todo TODO">TODO</span> The <code>.yas-make-groups</code> file</h2> <h2 id="sec-4"><span class="todo TODO">TODO</span> The <code>.yas-make-groups</code> file</h2>
<div class="outline-text-2" id="text-4"> <div class="outline-text-2" id="text-4">
<p> <p>
If you place an empty plain text file <code>.yas-make-groups</code> inside one If you place an empty plain text file <code>.yas-make-groups</code> inside one
of the mode directories, the names of these sub-directories are of the mode directories, the names of these sub-directories are
considered groups of snippets and <a href="#snippet-menu.org">the menu</a> is organized much more considered groups of snippets and <i>the menu</i> is organized much more
cleanly: cleanly:
</p> </p>
<p>
<img src="./images/menu-groups.png" alt="./images/menu-groups.png" />
<div class="figure">
<p><img src="./images/menu-groups.png" alt="menu-groups.png" />
</p> </p>
</div>
<p> <p>
Another way to achieve this is to place a <code># group:</code> directive Another way to achieve this is to place a <code># group:</code> directive
inside the snippet definition. See <a href="./snippet-development.html">Writing Snippets</a>. inside the snippet definition. See <a href="./snippet-development.html">Writing Snippets</a>.
</p> </p>
<pre class="example">
$ tree ruby-mode/
<pre class="example">$ tree ruby-mode/
ruby-mode/ ruby-mode/
|-- .yas-make-groups |-- .yas-make-groups
|-- collections |-- collections
@ -316,73 +320,57 @@ ruby-mode/
`-- ... `-- ...
</pre> </pre>
<p> <p>
Yet another way to create a nice snippet menu is to write into Yet another way to create a nice snippet menu is to write into
<code>.yas-make-groups</code> a menu definition. TODO <code>.yas-make-groups</code> a menu definition. TODO
</p> </p>
</div> </div>
</div> </div>
<div id="outline-container-5" class="outline-2"> <div id="outline-container-sec-5" class="outline-2">
<h2 id="sec-5"><span class="todo TODO">TODO</span> The <code>.yas-setup.el</code> file</h2> <h2 id="sec-5"><span class="todo TODO">TODO</span> The <code>.yas-setup.el</code> file</h2>
<div class="outline-text-2" id="text-5"> <div class="outline-text-2" id="text-5">
</div><div id="outline-container-sec-5-1" class="outline-3">
</div>
<div id="outline-container-5-1" class="outline-3">
<h3 id="sec-5-1"><span class="todo TODO">TODO</span> </h3> <h3 id="sec-5-1"><span class="todo TODO">TODO</span> </h3>
<div class="outline-text-3" id="text-5-1">
</div> </div>
</div> </div>
</div> <div id="outline-container-sec-6" class="outline-2">
<h2 id="sec-6">The <code>.yas-compiled-snippet.el</code> file</h2>
<div id="outline-container-6" class="outline-2">
<h2 id="sec-6"><span class="todo TODO">TODO</span> The <code>.yas-compiled-snippet.el</code> file</h2>
<div class="outline-text-2" id="text-6"> <div class="outline-text-2" id="text-6">
<p>
You may compile a top-level snippet directory with the
<code>yas-compile-directory</code> function, which will create a
</div> <code>.yas-compiled-snippets.el</code> file under each mode subdirectory,
which contains definitions for all snippets in the subdirectory.
<div id="outline-container-6-1" class="outline-3"> Compilation helps improve loading time.
<h3 id="sec-6-1"><span class="todo TODO">TODO</span></h3>
<div class="outline-text-3" id="text-6-1">
</div>
</div>
</div>
<div id="outline-container-7" class="outline-2">
<h2 id="sec-7"><span class="todo TODO">TODO</span> The <code>.yas-skip</code> file</h2>
<div class="outline-text-2" id="text-7">
</div>
<div id="outline-container-7-1" class="outline-3">
<h3 id="sec-7-1"><span class="todo TODO">TODO</span></h3>
<div class="outline-text-3" id="text-7-1">
</div>
</div>
</div>
</div>
<div id="postamble">
<hr><p class='creator'>Generated by <a href="http://orgmode.org">Org</a> version 7.9.3f with <a href="http://www.gnu.org/software/emacs/">Emacs</a> version 24 on 2014-10-01T21:16+0100 from 08b044e559cc350c6e7142d088ec2d4a82e378cb
</p> </p>
<p class='xhtml-validation'><a href="http://validator.w3.org/check?uri=referer">Validate XHTML 1.0</a></p>
<p>
Alternatively, you may compile all directories in the list
<code>yas-snippet-dirs</code> with the <code>yas-recompile-all</code> function.
</p>
</div>
</div>
<div id="outline-container-sec-7" class="outline-2">
<h2 id="sec-7">The <code>.yas-skip</code> file</h2>
<div class="outline-text-2" id="text-7">
<p>
A <code>.yas-skip</code> file in a mode's snippet subdirectory tells YASnippet
not to load snippets from there.
</p>
</div>
<div id="outline-container-sec-7-1" class="outline-3">
<h3 id="sec-7-1"><span class="todo TODO">TODO</span> </h3>
</div>
</div>
</div>
<div id="postamble" class="status">
<hr><p class='creator'>Generated by <a href="http://www.gnu.org/software/emacs/">Emacs</a> 24.4.91.1 (<a href="http://orgmode.org">Org</a> mode 8.2.10) on from 7703a55ac416a131dec45fa6a1e0ec1e31adf760
</p>
<p class='xhtml-validation'><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
</div> </div>
</body> </body>
</html> </html>

File diff suppressed because it is too large Load Diff