I am trying to use the cool YASnippet function: I am writing fragments containing Emacs Lisp inline code. There is a snippet for the first mode, which surrounds the entered text with "=", until the text, for example,
====
Text
====
Based on this snippet, I decided to modify it a bit (using Elisp) so that it would comment on these three lines depending on the main mode you are in (I thought such a snippet would be useful for organizing the source code), so I wrote following:
${1:`(insert comment-start)`} ${2:$(make-string (string-width text) ?\-)} $1 ${2:Text} $1 ${2:$(make-string (string-width text) ?\-)} $0
This code works relatively well, except for one problem: the indents of these three lines are mixed, depending on the main mode I'm in (for example, in emacslisp-mode, the second and third lines move more to the right than the first line).
I think the source of the problem may have something to do with what happens after the line ${1: in the first line. If I add a character, I have no problem (i.e., all three lines are correctly aligned at the end of the fragment extension). If I add one space after this line, the alignment problem is still ongoing.
So my question is: do you know of any way to rewrite this fragment so that this misalignment does not occur? Do you know what is the source of this behavior?
Greetings
source share