Trying to write a yasnippet for a markdown code block I wrote the following:

#name: Code Block
#contributor: Rovanion Luckey <rovanion.luckey@gmail.com>
# --


Since according to the documentation you have to escape the backquotes. Though when I try to call on the snippet in my markdown document I only get:


Worth mentioning is that neither



  • This looks like joaotavora/yasnippet#800, but I was unable to reproduce it, and neither was the OP after restarting Emacs. – npostavs Apr 27 '17 at 12:44
  • Hmm, I just restarted emacs and now it's working as intended. – Rovanion Apr 27 '17 at 13:07
  • Oh I didn't update yasnippet. I merely restarted emacs. I'm on version 0.11.0 right now. – Rovanion Apr 27 '17 at 14:16
  • Had you updated yasnippet there in the session where you got the bad result? And if so, which version did you update from? – npostavs Apr 27 '17 at 14:28
  • No, haven't touched my emacs packages for a month perhaps. This machine has definitely been restarted since. – Rovanion Apr 27 '17 at 14:54

The original example given in the question is correct, but due to a bug in yasnippet expanding a snippet which uses incorrect syntax will cause subsequent expansions to fail. For example, if you first tried


This fails to expand properly, producing YYYYY (with error Wrong type argument: char-or-string-p, (end-of-file)). That's because the backquotes are not escaped. But even after fixing it to


that still fails to expand properly, producing



(with error Wrong type argument: char-or-string-p, (${1:javascript})). If you keep expanding a few more times, it will eventually work, as the incorrect internal state gets removed.

The bug is fixed as of 2018 Feb 4, in what will be version 0.13. For older versions, it can be worked around by evaluating (setq yas--backquote-markers-and-strings nil).

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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