Subject: bug#39390: 28.0.50; prettify-symbols-mode confuses display when start/end faces are different

From: Tassilo Horn <[email-masked]>
Date: Mon, 17 Feb 2020 12:17:19 +0100

Raphael 'kena' Poss <[email-masked]> writes:

> https://asciinema.org/a/3nOh1zCJYHOeQ4uXk0rQ9akv8

No doubt you get strange display effects in your example, but I don't
know if that can be considered a bug given that your configuration is
illegal anyway.  See the docs of prettify-symbols-alist:

,----[ C-h v prettify-symbols-alist RET ]
| prettify-symbols-alist is a variable defined in ‘prog-mode.el’.
| Its value is nil
| 
|   Automatically becomes buffer-local when set.
| 
| Documentation:
| Alist of symbol prettifications.
| Each element looks like (SYMBOL . CHARACTER), where the symbol
| matching SYMBOL (a string, not a regexp) will be shown as
| CHARACTER instead.
| 
| CHARACTER can be a character, or it can be a list or vector, in
| which case it will be used to compose the new symbol as per the
| third argument of ‘compose-region’.
`----

I.e., the second element of each pair in `prettify-symbols-alist' is a
simple replacement glyph only in the case were it is a character.  You
provide strings instead, so the outcome can only be determined by
checking what `compose-region' does with that input.

AFAIK, `prettify-symbols-mode's intent is to replace programming
language symbols (like "lambda" in Lisp or >>= in Haskell) with a fancy
single Unicode character each, not to replace any text with any
arbitrary other text.  (Also, using multi-word matches like "setq abc"
or unbalanced expressions like "(push" is definitely asking for
trouble.)

Bye,
Tassilo