GNU bug report logs - #33139
12.1.1; Running syntax-ppss breaks font-latex

Previous Next

Package: auctex;

Reported by: Frank Dai <frankdai320 <at> gmail.com>

Date: Wed, 24 Oct 2018 15:23:02 UTC

Severity: normal

Tags: fixed

Found in version 12.1.1

Done: Ikumi Keita <ikumi <at> ikumi.que.jp>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 33139 in the body.
You can then email your comments to 33139 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-auctex <at> gnu.org:
bug#33139; Package auctex. (Wed, 24 Oct 2018 15:23:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Frank Dai <frankdai320 <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-auctex <at> gnu.org. (Wed, 24 Oct 2018 15:23:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Frank Dai <frankdai320 <at> gmail.com>
To: bug-auctex <at> gnu.org
Subject: 12.1.1; Running syntax-ppss breaks font-latex
Date: Wed, 24 Oct 2018 00:15:42 -0700
[Message part 1 (text/plain, inline)]
Hello AUCTeX maintainers,

Currently using smartparens with AUCTex will break font-latex non
deterministically. Attached is a screenshot of what it looks like when
broken. After some debugging, I concluded that the issue with
smartparens was that a 'yntax-ppss call was put into pre-command-hook.
The issue is reproductible with the following .emacs file (plus the
necessary AUCTeX importing) as well as an attached .tex:
(defun call-syntax-ppss ()
  (syntax-ppss))
(add-hook 'pre-command-hook 'call-syntax-ppss)

syntax-ppss should be stateless, so calling it should not affect
font-latex at all. The relevant changes that syntax-ppss makes is
modification of syntax-ppss-narrow (through syntax-ppss--data) in
lines 609-610 (in emacs-26.1) of syntax.el. I once found a case where
setting syntax-ppss--directly broke fontification, without even
calling syntax-ppss at all (but as it is nondeterministic, it no
longer works).

I have found a workaround, by putting the following line in .emacs
(add-hook 'LaTeX-mode-hook (lambda () (add-to-list
'font-latex-extend-region-functions  (lambda (min max) (point-min)))))
The idea behind this function was just to always extend the region to
the beginning of the buffer when fontifying. It seems to work, even
with syntax-ppss in 'pre-command-hook. From some cursory debugging,
none of the current functions in 'font-latex-extend-region-functions
check for presence of an unclosed $ or $$, which make it seem to me
that merely adding a function to check for an unclosed $ or $$ (or
modifying an existing one to do so) would fix this issue.

Thanks,
Frank Dai
[Screenshot from 2018-10-23 23-38-30.png (image/png, attachment)]
[hw.tex (text/x-tex, attachment)]

Information forwarded to bug-auctex <at> gnu.org:
bug#33139; Package auctex. (Wed, 03 Jun 2020 07:30:02 GMT) Full text and rfc822 format available.

Message #8 received at 33139 <at> debbugs.gnu.org (full text, mbox):

From: Ikumi Keita <ikumi <at> ikumi.que.jp>
To: Frank Dai <frankdai320 <at> gmail.com>
Cc: 33139 <at> debbugs.gnu.org
Subject: Re: bug#33139: 12.1.1; Running syntax-ppss breaks font-latex
Date: Wed, 03 Jun 2020 16:29:39 +0900
Dear Frank,

We are very sorry for taking such a long period to respond. We couldn't
reproduce what you described until recently, but at last managed to
develop a prescription to reproduce the symptom reliably, in the course
of chase of another bug.

Now we have just fixed this bug. Please try the latest development
version in the git repository or the ELPA release which is to be appear
soon.

Thank you very much for providing the sample hw.tex file and the
analysis that `syntax-ppss' is involved in the core of this bug. They
were valuable in the course of tackling down this bug.

Best regards,
Ikumi Keita

P.S. For record, I write down the prescription to reproduce this bug
reliably before this bug is closed. It seems that the size of the emacs
frame is an important factor whether and where this bug appears:
1. Save the following init.el under ~/.emacs.d/. (After backing up the
   original init.el, of course)
----------------------------------------------------------------------
(defun call-syntax-ppss ()
  (syntax-ppss))
(add-hook 'pre-command-hook 'call-syntax-ppss)
(load "auctex.el" nil t t)
----------------------------------------------------------------------
2. Start a new emacs session by
emacs -geometry 140x35 &
3. Open the example file hw.tex and type C-v three times.
4. Then the several paragraphs beginning with "Recall that $b$ is
   algebraic ..." get fontified wrongly, where normal texts are given
   math face and math expressions are without particular face.

>>>>> Frank Dai <frankdai320 <at> gmail.com> writes:
> Hello AUCTeX maintainers,
> Currently using smartparens with AUCTex will break font-latex non
> deterministically. Attached is a screenshot of what it looks like when
> broken. After some debugging, I concluded that the issue with
> smartparens was that a 'yntax-ppss call was put into pre-command-hook.
> The issue is reproductible with the following .emacs file (plus the
> necessary AUCTeX importing) as well as an attached .tex:
> (defun call-syntax-ppss ()
>   (syntax-ppss))
> (add-hook 'pre-command-hook 'call-syntax-ppss)

> syntax-ppss should be stateless, so calling it should not affect
> font-latex at all. The relevant changes that syntax-ppss makes is
> modification of syntax-ppss-narrow (through syntax-ppss--data) in
> lines 609-610 (in emacs-26.1) of syntax.el. I once found a case where
> setting syntax-ppss--directly broke fontification, without even
> calling syntax-ppss at all (but as it is nondeterministic, it no
> longer works).

> I have found a workaround, by putting the following line in .emacs
> (add-hook 'LaTeX-mode-hook (lambda () (add-to-list
> 'font-latex-extend-region-functions  (lambda (min max) (point-min)))))
> The idea behind this function was just to always extend the region to
> the beginning of the buffer when fontifying. It seems to work, even
> with syntax-ppss in 'pre-command-hook. From some cursory debugging,
> none of the current functions in 'font-latex-extend-region-functions
> check for presence of an unclosed $ or $$, which make it seem to me
> that merely adding a function to check for an unclosed $ or $$ (or
> modifying an existing one to do so) would fix this issue.




Added tag(s) fixed. Request was from Ikumi Keita <ikumi <at> ikumi.que.jp> to control <at> debbugs.gnu.org. (Sat, 11 Jul 2020 17:26:01 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 33139 <at> debbugs.gnu.org and Frank Dai <frankdai320 <at> gmail.com> Request was from Ikumi Keita <ikumi <at> ikumi.que.jp> to control <at> debbugs.gnu.org. (Sat, 11 Jul 2020 17:26:01 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 09 Aug 2020 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 260 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.