2

I stumbled upon this feature for functions, and was eager to try it out.

However, I ran into an error message, after trying the snippet in python-mode:

[yas] elisp error: Symbol’s value as variable is void: text

From what I read on his blog, and seeing the others trying this snippet, it went propably without any problems for them. I couldn't figure out how I could bind any value to the text. Any suggestion?

5
  • 1
    Please provide more information. You should be able to find out where in the source code the text is that it is referring to. Post some of that code and it should be easy to help you. Looking at the page you cite, and searching for text, this part of the code seems problematic, as variable text in it indeed looks like a free variable: (mapcar '(lambda (x) (split-string x "=")) (split-string text ",")). Try setting debug-on-error to t and showing a backtrace.
    – Drew
    Commented Mar 5, 2016 at 22:32
  • I copied the source code of the yasnippet custom snippet de, as displayed on that page. The variable text is indeed not defined yet, as the backtrace told me. So it seems the author didn't delivered a working example of the source code. But I thought it was only me. You ran into an error too, I assume?
    – ReneFroger
    Commented Mar 5, 2016 at 23:57
  • I didn't run into an error. I didn't try it. If you post the backtrace perhaps someone can help you further. That was the point.
    – Drew
    Commented Mar 6, 2016 at 1:14
  • When debug-on-error toggled to t, I didn't get any backtrace when the error occured. I got only that error message inside the yasnippet. Because the error occured when Yasnippet tried to interpret the snippet, and not Emacs, I guess.
    – ReneFroger
    Commented Mar 6, 2016 at 15:47
  • I see. Maybe someone familiar with YAS will have a suggestion.
    – Drew
    Commented Mar 6, 2016 at 16:06

1 Answer 1

3

The text variable is the old version of the contents of the field you're currently expanding/writing. I guess the name was too generic so in later versions of yasnippet it was replaced with the variable yas-text instead.

You should try replacing it with that and see if that helps.

1
  • Oh Xaldew, you're right. Thanks for sharing!
    – ReneFroger
    Commented Mar 7, 2016 at 22:46

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.