From b19daa31ca50d0a696ee39e0ac9d5b27eac1d8b1 Mon Sep 17 00:00:00 2001 From: "Duong H. Nguyen" Date: Wed, 23 Oct 2013 04:25:45 +0700 Subject: [PATCH] Fix docs, organizing snippet section: using yas-snippet-dirs instead of the deprecated yas/root-directory --- snippet-organization.html | 59 ++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/snippet-organization.html b/snippet-organization.html index 020389d..7944809 100644 --- a/snippet-organization.html +++ b/snippet-organization.html @@ -82,32 +82,47 @@ intended.

The non-bundle version of YASnippet, once unpacked, comes with a full directory of snippets, which you can copy somewhere and use. You can also create or download more directories.

-

Once these directories are in place reference them in the variable -yas/root-directory and load them with yas/load-directory:

-
;; Develop and keep personal snippets under ~/emacs.d/mysnippets
-(setq yas/root-directory "~/emacs.d/mysnippets")
 
-;; Load the snippets
-(yas/load-directory yas/root-directory)
-
-

The point in using yas/root-directory (as opposed to calling -yas/load-directory directly) is considering "~/emacs.d/mysnippets" -for snippet development, so you can use commands like -yas/new-snippet and others described in section Writing -Snippets.

-

You can make this variable a list and store more items into it:

-
;; Develop in ~/emacs.d/mysnippets, but also
-;; try out snippets in ~/Downloads/interesting-snippets
-(setq yas/root-directory '("~/emacs.d/mysnippets"
-                           "~/Downloads/interesting-snippets"))
+

+ Once these directories are in place reference them in the variable + + yas-snippet-dirs + + and then load YASnippet as usual: +

-;; Map `yas/load-directory' to every element -(mapc 'yas/load-directory yas/root-directory) +
+
;; Develop and keep personal snippets under ~/emacs.d/mysnippets
+(setq yas-snippet-dirs '("~/emacs.d/mysnippets"))
+
+;; Load yasnippet
+(yas-global-mode 1)
 
-

In this last example, the all the directories are loaded and their -snippets considered for expansion. However development still happens -in the first element, "~/emacs.d/mysnippets".

+ +

+ The point in using + + yas-snippet-dirs + + is considering "~/emacs.d/mysnippets" for snippet development, so + you can use commands like + + yas/new-snippet + + and others described in section + Writing Snippets. +

+ +

+ Note: In the past, + + yas/root-directory + + is the variable that stores the list of snippet directories. This method is + deprecated and only exists for backward-compatibility reason. +

+

Organizing snippets

Once you've setup yas/root-directory , you can store snippets