Subject: Re: bug#78752: 31.0.50; New tex-mode prettify-symbols-mode rule causes visual regression

From: Arash Esbati <[email-masked]>
Date: Wed, 11 Jun 2025 16:11:35 +0200

"Paul D. Nelson" <[email-masked]> writes:

> Tony Zorman <[email-masked]> writes:
>
>> (this change certainly isn't as bad as the long established
>> replacement of showing '\newline' as LINE SEPARATOR, making it
>> essentially invisible by default).
>
> I guess I haven't run into TeX \newline's often enough to notice this,
> but it's invisible for me, too.  @Tassilo: any thoughts on this one?

I'm not Tassilo, but my suggestion is to remove the entries for '\newline'
and '\ ' from the prettification-list.  Consider this piece of valid
LaTeX-code:

--8<---------------cut here---------------start------------->8---
\_%
\begin{tabular}[t]{p{5cm}l}
  foo\newline bar & baz
\end{tabular}
\_

\_\parbox[t]{5cm}{Term-\\ S.}\_

\_\parbox[t]{5cm}{Term-\\S.}\_
--8<---------------cut here---------------end--------------->8---

which is prettified to this:

\newline is effectively gone, and what happens after \\ is also wrong.
I'm not sure, but I think the \parbox examples above show a bug in
`tex--prettify-symbols-compose-p' which should also check if the
character(s) before the currently ignored START is(are) backslashes, and
if yes, how many, and then prettify or not.  AUCTeX has this for this
purpose:

--8<---------------cut here---------------start------------->8---
(defun TeX-escaped-p (&optional pos)
  "Return t if the character at position POS is escaped.
If POS is omitted, examine the character at point.
A character is escaped if it is preceded by an odd number of
escape characters, such as \"\\\" in LaTeX."
  (save-excursion
    (when pos (goto-char pos))
    (not (zerop (mod (skip-chars-backward (regexp-quote TeX-esc)) 2)))))
--8<---------------cut here---------------end--------------->8---

I'm Cc'ing Stefan M. who maintains tex-mode.el.

Best, Arash