1

NOTE: I use the symbol to represent the character SPACE (U+0020) for visibility.

I have a template like this:

${1:$$(yas-choose-value (with-current-buffer "foo-buf" (foo-get-name-list)))}␣[label="$1"];

When I pick an entry "Foo" from the list returned from foo-get-name-list, I expect to see an output line like

Foo␣[label="Foo"]

Instead, however, I get

Foo[label="Foo"]

How can I preserve that SPACE after Foo and before the LEFT SQUARE BRACKET?

  • 2
    Please choose only one forum, not both: stackoverflow.com/questions/39375355/… – lawlist Sep 7 '16 at 17:29
  • Sorry, @lawlist. After I posted on S/O, I remembered the existence of this forum and realized I should have posted here. I didn't see an obvious way to move the question. – Colin Fraizer Sep 8 '16 at 11:31
1

The problem is that the $$(yas-choose-value... is not expanded before the indentation kicks in, so when yasnippet indents the snippet, the buffer text looks like: ␣[label=""]; and the space is removed by indenting. You can disable indentation for a snippet by adding # expand-env: ((yas-indent-line nil)) to the snippet.

I'm not sure yet whether to classify this as a yasnippet bug or not.

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.