mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-14 05:23:04 +00:00
Fix docs, organizing snippet section: using yas-snippet-dirs instead of the deprecated yas/root-directory
This commit is contained in:
parent
4f3f185912
commit
b19daa31ca
@ -82,32 +82,47 @@ intended.</p>
|
|||||||
<p>The non-bundle version of YASnippet, once unpacked, comes with a full
|
<p>The non-bundle version of YASnippet, once unpacked, comes with a full
|
||||||
directory of snippets, which you can copy somewhere and use. You can
|
directory of snippets, which you can copy somewhere and use. You can
|
||||||
also create or download more directories.</p>
|
also create or download more directories.</p>
|
||||||
<p>Once these directories are in place reference them in the variable
|
|
||||||
<tt class="docutils literal"><span class="pre">yas/root-directory</span></tt> and load them with <tt class="docutils literal"><span class="pre">yas/load-directory</span></tt>:</p>
|
|
||||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span style="color: #408080; font-style: italic">;; Develop and keep personal snippets under ~/emacs.d/mysnippets</span>
|
|
||||||
(<span style="color: #008000; font-weight: bold">setq</span> <span style="color: #19177C">yas/root-directory</span> <span style="color: #BA2121">"~/emacs.d/mysnippets"</span>)
|
|
||||||
|
|
||||||
<span style="color: #408080; font-style: italic">;; Load the snippets</span>
|
<p>
|
||||||
(<span style="color: #19177C">yas/load-directory</span> <span style="color: #19177C">yas/root-directory</span>)
|
Once these directories are in place reference them in the variable
|
||||||
</pre></div>
|
<tt class="docutils literal">
|
||||||
<p>The point in using <tt class="docutils literal"><span class="pre">yas/root-directory</span></tt> (as opposed to calling
|
<span class="pre">yas-snippet-dirs</span>
|
||||||
<tt class="docutils literal"><span class="pre">yas/load-directory</span></tt> directly) is considering "~/emacs.d/mysnippets"
|
</tt>
|
||||||
for snippet development, so you can use commands like
|
and then load YASnippet as usual:
|
||||||
<tt class="docutils literal"><span class="pre">yas/new-snippet</span></tt> and others described in section <a class="reference external" href="snippet-development.html">Writing
|
</p>
|
||||||
Snippets</a>.</p>
|
|
||||||
<p>You can make this variable a list and store more items into it:</p>
|
|
||||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span style="color: #408080; font-style: italic">;; Develop in ~/emacs.d/mysnippets, but also</span>
|
|
||||||
<span style="color: #408080; font-style: italic">;; try out snippets in ~/Downloads/interesting-snippets</span>
|
|
||||||
(<span style="color: #008000; font-weight: bold">setq</span> <span style="color: #19177C">yas/root-directory</span> <span style="color: #666666">'</span>(<span style="color: #BA2121">"~/emacs.d/mysnippets"</span>
|
|
||||||
<span style="color: #BA2121">"~/Downloads/interesting-snippets"</span>))
|
|
||||||
|
|
||||||
<span style="color: #408080; font-style: italic">;; Map `yas/load-directory' to every element</span>
|
<div class="highlight" style="background: #f8f8f8">
|
||||||
(<span style="color: #008000">mapc</span> <span style="color: #19177C">'yas/load-directory</span> <span style="color: #19177C">yas/root-directory</span>)
|
<pre style="line-height: 125%"><span style="color: #408080; font-style: italic">;; Develop and keep personal snippets under ~/emacs.d/mysnippets</span>
|
||||||
|
(<span style="color: #008000; font-weight: bold">setq</span> <span style="color: #19177C">yas-snippet-dirs</span> <span style="color: #666666">'</span>(<span style="color: #BA2121">"~/emacs.d/mysnippets"</span>))
|
||||||
|
|
||||||
|
<span style="color: #408080; font-style: italic">;; Load yasnippet</span>
|
||||||
|
(<span style="color: #19177C">yas-global-mode</span> <span style="color: #19177C">1</span>)
|
||||||
</pre></div>
|
</pre></div>
|
||||||
<p>In this last example, the all the directories are loaded and their
|
|
||||||
snippets considered for expansion. However development still happens
|
<p>
|
||||||
in the first element, "~/emacs.d/mysnippets".</p>
|
The point in using
|
||||||
|
<tt class="docutils literal">
|
||||||
|
<span class="pre">yas-snippet-dirs</span>
|
||||||
|
</tt>
|
||||||
|
is considering "~/emacs.d/mysnippets" for snippet development, so
|
||||||
|
you can use commands like
|
||||||
|
<tt class="docutils literal">
|
||||||
|
<span class="pre">yas/new-snippet</span>
|
||||||
|
</tt>
|
||||||
|
and others described in section
|
||||||
|
<a class="reference external" href="snippet-development.html">Writing Snippets</a>.
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<strong>Note:</strong> In the past,
|
||||||
|
<tt class="docutils literal">
|
||||||
|
<span class="pre">yas/root-directory</span>
|
||||||
|
</tt>
|
||||||
|
is the variable that stores the list of snippet directories. This method is
|
||||||
|
deprecated and only exists for backward-compatibility reason.
|
||||||
|
</p>
|
||||||
|
|
||||||
<div class="section" id="id2">
|
<div class="section" id="id2">
|
||||||
<h1><a class="toc-backref" href="#id4">Organizing snippets</a></h1>
|
<h1><a class="toc-backref" href="#id4">Organizing snippets</a></h1>
|
||||||
<p>Once you've setup <tt class="docutils literal"><span class="pre">yas/root-directory</span></tt> , you can store snippets
|
<p>Once you've setup <tt class="docutils literal"><span class="pre">yas/root-directory</span></tt> , you can store snippets
|
||||||
|
Loading…
x
Reference in New Issue
Block a user