I am unable to set up yasnippet the way I want to set it up.

I only want to use yasnippet for a particular set of modes, so I don't want to use yas-global-mode.

I only want to use my own snippets, not the ones that come pre-packaged with the MELPA installation. I don't want it to ever load the MELPA snippets.

Unfortunately, the package is being insufferable; the only way I can figure out how to add my snippets and get them to actually work is to do the following:

(require 'yasnippet)

;; Use custom snippets.
(add-to-list 'yas-snippet-dirs "~/Dropbox/configs/emacs/snippets/")

(dolist (hook jrh-programming-modes)
  (add-hook hook 'yas-minor-mode))

I have to call yas-reload-all, or else my snippets aren't available. I have to use add-to-list, because for some reason, when I replace that line with (setq yas-snippet-dirs '("~/Dropbox/configs/emacs/snippets/")), my snippets are not loaded. So I have to suffer through the loading of all the other snippets, which I never use.

What I would like to do is this:

;; Use custom snippets.
(setq yas-snippet-dirs '("~/Dropbox/configs/emacs/snippets/"))

(require 'yasnippet)

(dolist (hook jrh-programming-modes)
  (add-hook hook 'yas-minor-mode))

and never need to use the other snippets or reload at all. Of course, the above code does not work, even though in my head it seems like it should.

Any help on how to accomplish this would be greatly appreciated.

  • Take it up with github.com/capitaomorte/yasnippet/issues. yasnippet hasn't worked without yas-global-mode for ages.
    – abo-abo
    Jan 10, 2015 at 15:26
  • How about the line of code in the enabling of yas-minor-mode that says: (dolist (mode (yas--modes-to-activate)) . . . Is that what you're looking for?
    – lawlist
    Jan 11, 2015 at 4:39

1 Answer 1


From yas-minor-mode does not load snippets (GitHub):

I think when not using yas-global-mode you have to at least add a (yas-reload-all) call somewhere to your .emacs. This will setup the jit-loading tables (and not load actual snippets until yas-minor-mode is activated in some buffer for which one of those tables has been setup.

It might be desirable to have this performed automatically, but I think I've analysed this in the past and found it to not be suitable (for some reason that I can't quite remember right now, sorry).

Anyway, you have a workaround: add (yas-reload-all) somewhere in your init file.

This is a bug; the solution I have discovered is the maintainer's recommended workaround in the interim.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.