yas/root-directory now can contains a list of directories

This commit is contained in:
Zhang Chiyuan 2008-04-11 03:58:40 +00:00
parent 4f0c2cb993
commit 5bd14c4b18

View File

@ -3,7 +3,7 @@
;; Copyright 2008 pluskid ;; Copyright 2008 pluskid
;; ;;
;; Author: pluskid <pluskid@gmail.com> ;; Author: pluskid <pluskid@gmail.com>
;; Version: 0.4.5 ;; Version: 0.5.0
;; X-URL: http://code.google.com/p/yasnippet/ ;; X-URL: http://code.google.com/p/yasnippet/
;; This file is free software; you can redistribute it and/or modify ;; This file is free software; you can redistribute it and/or modify
@ -50,7 +50,8 @@ foo-bar
will first try \"bar\", if not found, then \"foo-bar\" is tried.") will first try \"bar\", if not found, then \"foo-bar\" is tried.")
(defvar yas/root-directory nil (defvar yas/root-directory nil
"The root directory that stores the snippets for each major modes.") "The (list of) root directory that stores the snippets for each
major modes.")
(defvar yas/indent-line t (defvar yas/indent-line t
"Each (except the 1st) line of the snippet template is indented to "Each (except the 1st) line of the snippet template is indented to
@ -177,7 +178,7 @@ to expand.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Internal variables ;; Internal variables
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar yas/version "0.4.5") (defvar yas/version "0.5.0")
(defvar yas/snippet-tables (make-hash-table) (defvar yas/snippet-tables (make-hash-table)
"A hash table of snippet tables corresponding to each major-mode.") "A hash table of snippet tables corresponding to each major-mode.")
@ -1020,7 +1021,10 @@ all the parameters:
"Reload all snippets." "Reload all snippets."
(interactive) (interactive)
(if yas/root-directory (if yas/root-directory
(yas/load-directory-1 yas/root-directory) (if (listp yas/root-directory)
(dolist (directory yas/root-directory)
(yas/load-directory directory))
(yas/load-directory yas/root-directory))
(call-interactively 'yas/load-directory)) (call-interactively 'yas/load-directory))
(message "done.")) (message "done."))
@ -1031,8 +1035,9 @@ name. And under each subdirectory, each file is a definition
of a snippet. The file name is the trigger key and the of a snippet. The file name is the trigger key and the
content of the file is the template." content of the file is the template."
(interactive "DSelect the root directory: ") (interactive "DSelect the root directory: ")
(unless yas/root-directory (when (and (interactive-p)
(setq yas/root-directory directory)) (file-directory-p directory))
(add-to-list 'yas/root-directory directory))
(dolist (dir (yas/directory-files directory nil)) (dolist (dir (yas/directory-files directory nil))
(yas/load-directory-1 dir)) (yas/load-directory-1 dir))
(when (interactive-p) (when (interactive-p)