Suppose, I have 2 subdirectories for yasnippets:
~/.emacs.d/yasnippets/perl-mode
~/.emacs.d/yasnippets/php-mode
Currently I use the following code in my .emacs:
(defvar *my-emacs-lib-dir* "~/.emacs.d/")
(load (concat *my-emacs-lib-dir* "plugins/yasnippet/yasnippet"))
(setq yas/snippet-dirs nil)
(yas/initialize)
;; Develop and keep personal snippets under ~/emacs.d/yasnippets
(setq yas/root-directory (concat *my-emacs-lib-dir* "yasnippets"))
(yas/load-directory yas/root-directory)
So, it loads all the yasnippets in all the subdirectories of ~/.emacs.d/yasnippets.
Is it possible to make it load the yasnippets on demand? If I open a php file, and the snippets for php-mode were not loaded, load them. But not load everything on startup.