Could anyone please suggest a method to surround a region that contains a leading \$
and surround it with a snippet. In latex-mode
, I am frequently underlining or double-underlining monies due and the yasnippet being used removes the backslash. I'd like to be able to use the same snippet for all situations -- with or without a leading \$
.
# -*- mode: snippet -*-
# contributor: lawlist
# key: underline_selected
# group: font
# name: underline_selected
# binding: C-I u s
# --
\uline{`yas/selected-text`}
There are few problems that cause the behavior described by the original poster, who uses a custom modified version of
tex-mode.el
, not AUCTeX.First, the function
yas--snippet-parse-create
contains, among other codes, the following functions that do not play well with LaTeX escaped dollar signs:Second, the variable
yas--simple-mirror-regexp
catches dollar amounts, in addition to the standard yasnippet fields such as$1
. When the above-mentioned(yas--delete-regions yas--dollar-regions)
is called byyas--snippet-parse-create
, the result is an erroneous deletion. The author of this answer has modified the regexp to exclude a dollar-sign with a preceding backslash:The author of this answer does not presently have a fix for
yas--protect-escapes
andyas--restore-escapes
, and has merely commented them out in the meantime. [This would obviously be problematic for anyone doing programming, but appears to be sufficient for merely writing LaTeX documents.] An issue has been opened on Github and the author of this answer will update this thread if a solution is found there.