mirror of
https://github.com/joaotavora/yasnippet.git
synced 2026-02-04 06:32:24 +00:00
@@ -7,7 +7,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"/>
|
||||
<meta name="title" content="Writing snippets"/>
|
||||
<meta name="generator" content="Org-mode"/>
|
||||
<meta name="generated" content="2013-11-28T23:36-0500"/>
|
||||
<meta name="generated" content="2013-12-02T19:38+0000"/>
|
||||
<meta name="author" content=""/>
|
||||
<meta name="description" content=""/>
|
||||
<meta name="keywords" content=""/>
|
||||
@@ -158,7 +158,6 @@ for the JavaScript code in this tag.
|
||||
<li><a href="#sec-3-9">Nested placeholder fields</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#sec-4">Importing TextMate snippets</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@@ -298,10 +297,10 @@ Here's a list of currently supported directives:
|
||||
|
||||
|
||||
<p>
|
||||
This is the probably the most important directive, it's the abbreviation
|
||||
you type to expand a snippet just before hitting <a href="snippet-reference.html#yas-trigger-key"><code>yas-trigger-key</code></a>. If
|
||||
you don't specify this the snippet will not be expandable through the
|
||||
key mechanism.
|
||||
This is the probably the most important directive, it's the
|
||||
abbreviation you type to expand a snippet just before hitting the key
|
||||
that runs <a href="snippet-reference.html#yas-expand"><code>yas-expand</code></a>. If you don't specify this
|
||||
the snippet will not be expandable through the trigger mechanism.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -496,7 +495,7 @@ escaped as <code>\\</code> sometimes.
|
||||
Emacs-Lisp code can be embedded inside the template, written inside
|
||||
back-quotes (==). The lisp forms are evaluated when the snippet is
|
||||
being expanded. The evaluation is done in the same buffer as the
|
||||
snippet being expanded.
|
||||
snippet being expanded.
|
||||
</p>
|
||||
<p>
|
||||
Here's an example for c-mode` to calculate the header file guard
|
||||
@@ -785,14 +784,13 @@ enter snippet field 2. This one makes use of <a href="snippet-reference.html#yas
|
||||
<pre class="example">\section{${1:"Titel der Tour"}}%
|
||||
\index{$1}%
|
||||
\label{{2:"waiting for reftex-label call..."$(unless yas-modified-p (reftex-label nil 'dont-
|
||||
insert))}}%
|
||||
insert))}}%
|
||||
</pre>
|
||||
|
||||
|
||||
<p>
|
||||
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>
|
||||
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>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -824,89 +822,13 @@ the exit marker.
|
||||
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
|
||||
performs the normal Emacs <code>delete-char</code> command.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="outline-container-4" class="outline-2">
|
||||
<h2 id="sec-4">Importing TextMate snippets</h2>
|
||||
<div class="outline-text-2" id="text-4">
|
||||
|
||||
|
||||
<p>
|
||||
There are a couple of tools that take TextMate's ".tmSnippet" xml files
|
||||
and create YASnippet definitions:
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li><a href="http://code.nokrev.com/?p=snippet-copier.git;a=blob_plain;f=snippet_copier.py">a python script by Jeff Wheeler</a>
|
||||
|
||||
</li>
|
||||
<li>a <a href="http://yasnippet.googlecode.com/svn/trunk/extras/textmate_import.rb">ruby tool</a> , <code>textmate_import.rb</code> adapted from <a href="http://www.neutronflux.net/2009/07/28/shoulda-snippets-for-emacs/">Rob Christie's</a>,
|
||||
which I have uploaded to the repository.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
<p>
|
||||
In this section, i'll shortly cover the <b>second</b> option.
|
||||
</p>
|
||||
<p>
|
||||
Download the <code>textmate_import.rb</code> tool and the TextMate bundle you're
|
||||
interested in.
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
<pre class="example">$ curl -O http://yasnippet.googlecode.com/svn/trunk/extras/textmate_import.rb
|
||||
$ svn export http://svn.textmate.org/trunk/Bundles/HTML.tmbundle/
|
||||
</pre>
|
||||
|
||||
|
||||
<p>
|
||||
Then invoke <code>textmate_import.rb</code> like this:
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
<pre class="example">$ ./textmate_import.rb -d HTML.tmbundle/Snippets/ -o html-mode -g HTML.tmbundle/info.plist
|
||||
</pre>
|
||||
|
||||
|
||||
<p>
|
||||
You should end up with a <code>html-mode</code> subdir containing snippets exported
|
||||
from textmate.
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
<pre class="example">$ tree html-mode # to view dir contents, if you have 'tree' installed
|
||||
</pre>
|
||||
|
||||
|
||||
<p>
|
||||
The <code>-g</code> is optional but helps the tool figure out the grouping.
|
||||
According to <a href="./snippet-organization.html">Organizing Snippets</a>, don't forget to touch
|
||||
<code>.yas-make-groups</code> and <code>.yas-ignore-filename-triggers</code> inside the
|
||||
<code>html-mode</code> dir.
|
||||
</p>
|
||||
<p>
|
||||
Also try <code>textmate_import.rb --help</code> for a list of options.
|
||||
</p>
|
||||
<p>
|
||||
Please note that snippet importation is not yet perfect. You'll probably
|
||||
have some adjustments to some/many snippets. Please contribute these
|
||||
adjustments to the google group or, better yet, patch the
|
||||
<code>textmate_import.rb</code> to automatically perform them and submit that.
|
||||
</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 2013-11-28T23:36-0500 from eda83304afc7894f0b5ddc15b04b041be52b94fb
|
||||
<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 2013-12-02T19:38+0000 from 582e3680b66a62f304034376516207c006f77fe4
|
||||
</p>
|
||||
<p class='xhtml-validation'><a href="http://validator.w3.org/check?uri=referer">Validate XHTML 1.0</a></p>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user