1

I recently upgraded to yasnippet 0.10.0, on emacs 24.5.1/OS X and noticed that some of my yasnippets are not loaded anymore, but this only affects some. I can see that these are still in the compiled list of snippet, but entering the snippet key and TAB doesn't do anything anymore.

I tried reloading and recompiling the list of yasnippets, but didn't have any luck.

One of the snippets that doesn't work anymore looks like this:

# -*- mode: snippet; require-final-newline: nil -*-
# name: function
# key: lerj
# --
error_log(json_encode($0));

My yasnippet setup:

(setq yas-snippet-dirs '("~/Documents/playground/emacs/my-emacs-config/yasnippet-snippets"))

In the compiled file .yas-compiled-snippets.el I can also see that the snippet is registered:

("lerj" "lerj\n$0" "function" nil nil nil "/Users/max/Documents/playground/emacs/my-emacs-config/yasnippet-snippets/php-mode/log-error-json_encode" nil nil)

But also when executing yas-describe-tables only 2 snippets are liseted, but not the lerj one.

I only noticed that behaviour since I upgraded yasnippet to a more recent version, but I couldn't find any similar bug report.

2
  • Do you have any other snippets named function? Perhaps it's being overwritten.
    – npostavs
    Commented Nov 14, 2016 at 14:14
  • @npostavs thank you that was the hint, i had name: function copy/pasted in some other templates, previously this wasn't an issue apparently, now they stopped working. Fixed that, thanks! If you want to write an answer, I will accept it.
    – BMBM
    Commented Nov 15, 2016 at 0:28

1 Answer 1

0

Loading a new snippet with the same name as an older one will overwrite the older one. A similar issue is #548:

I'm not sure if having 2 snippets with the same name is supposed to work.

It isn't. Two snippets with the same key is fine though, and the name differentiates them.

Another way to differentiate snippets is with the uuid attribute. Loading a new snippet with the same name as an older one, but different uuid should not overwrite the older one.

So make sure your snippets have unique name or uuid attributes.

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.