Andreas Röhler <andreas.roehler@easy-emacs.de> writes:
It's not about duplication, but derivation. The original DTRT in most
cases.
Point of interest are the exceptions - see for example in Elixir
https://github.com/elixir-lang/emacs-elixir/issues/185
"\"foo\"" |> String.strip(?")
Where the doublquote after question mark makes Emacs think it's a
string-start - which isn't.
String recognition in emacs is usually done using syntax tables, so get
the elixir syntax table right and then you don't need any workarounds.
In this case, it seems plain syntax tables aren't enough, though, so the
elisp docs explain how to override certain characters' syntax on demand.
,----[ (info "(elisp)Syntax Properties") ]
| When the syntax table is not flexible enough to specify the syntax of a
| language, you can override the syntax table for specific character
| occurrences in the buffer, by applying a ‘syntax-table’ text property.
| *Note Text Properties::, for how to apply text properties.
`----
So basically, you (or elixir-mode) will want to define a
`syntax-propertize-function' which finds occurrences of ?" and gives "/"
(character quote) syntax to the ? in which the usual "\"" (string
quotes) syntax of `"' would be ineffective for this single double quote.
,----[ (info "(elisp)Syntax Class Table") ]
| Character quotes: ‘/’
| Characters used to quote the following character so that it loses
| its normal syntactic meaning. This differs from an escape
| character in that only the character immediately following is ever
| affected.
|
| Characters in this class count as part of words if
| ‘words-include-escapes’ is non-‘nil’. *Note Word Motion::.
`----
Bye,
Tassilo