From: Alan Mackenzie <acm@muc.de>
To: Amol Surati <suratiamol@gmail.com>
Cc: acm@muc.de, Eli Zaretskii <eliz@gnu.org>,
Stephen Berman <stephen.berman@gmx.net>,
70367@debbugs.gnu.org
Subject: bug#70367: 30.0.50; Inconsistent Syntax Highlighting
Date: Sun, 14 Apr 2024 02:46:26 +0000 [thread overview]
Message-ID: <ZhtDgkpI2ITs0jIa@ACM> (raw)
In-Reply-To: <CA+nuEB-gZGoMXUZY==ydC_Y3zWGFanpxyJEWgWmUcVu1F+C82w@mail.gmail.com>
Hello, Amol.
Thanks for taking the trouble to report this bug, and thanks even more
for the convenient test file generator, which was extremely helpful.
On Sun, Apr 14, 2024 at 03:44:01 +0530, Amol Surati wrote:
> On Sun, 14 Apr 2024 at 00:35, Eli Zaretskii <eliz@gnu.org> wrote:
> > > From: Stephen Berman <stephen.berman@gmx.net>
> > > Cc: suratiamol@gmail.com, 70367@debbugs.gnu.org
> > > Date: Sat, 13 Apr 2024 21:00:16 +0200
> > > On Sat, 13 Apr 2024 20:48:28 +0300 Eli Zaretskii <eliz@gnu.org> wrote:
> > > >> Cc: 70367@debbugs.gnu.org
> > > >> Date: Sat, 13 Apr 2024 20:44:37 +0300
> > > >> From: Eli Zaretskii <eliz@gnu.org>
> > > >> > From: Amol Surati <suratiamol@gmail.com>
> > > >> > Date: Sat, 13 Apr 2024 18:12:54 +0530
> > > >> > The problem is not found in terminal emacs built from the released 29.3.tar.gz,
> > > >> > or with emacs running under GUI (i.e. under PGTK).
> > > >> > The problem is seen with terminal emacs built from the master branch, at various
> > > >> > commit levels.
> > > >> > Problem: When a large file (for e.g. vulkan_core.h) is opened, certain
> > > >> > constructs have their syntax highlighting broken. The video found at [1] shows
> > > >> > the behaviour. At the end of the video, one can see one instance of the problem;
> > > >> > the syntax highlighting for the enum constant
> > > >> > 'VK_STRUCTURE_TYPE_EVENT_CREATE_INFO = 10,' abruptly breaks. The entire
> > > >> > identifier VK_STRUCTURE_TYPE_EVENT_CREATE_INFO must be one colour. Instead,
> > > >> > 'VK_STRUCTURE_TYPE_EVENT_CREA' is of the expected colour, while
> > > >> > 'TE_INFO' is of the colour that is expected with '= 10,'. You may want to
> > > >> > download the video and then play it, if Google Drive plays it at a resolution
> > > >> > that is lower than the video's native resolution.
> > > >> > Within this same session, there were other such enum constants with broken
> > > >> > highlighting, though they have not been captured in the video.
> > > >> > The termscript is attached at [2].
> > > >> > The graphics session is Wayland with swaywm as its compositor; XWayland is
> > > >> > not enabled. The terminal emulator is 'foot'. Another terminal emulator,
> > > >> > 'alacritty' was also tested; the problem occurred there too.
> > > >> > The problem doesn't seem to occur with small-sized files; After reducing the
> > > >> > vulkan_core.h to contain only around 235 lines, emacs was able to show the
> > > >> > (reduced) file with consistent highlighting.
> > > I see exactly the same misfontification as the OP in the same file
> > > (which I happen to have on my system), as well as several more similar
> > > misfontifications further down in that file -- but only with c-mode from
> > > cc-mode.el. With c-ts-mode I see no misfontifications in that file.
> > > This is with GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+
> > > Version 3.24.41, cairo version 1.18.0) of 2024-04-11.
> > Strange. I see no misfontifications with either mode.
> Apologies. I missed Eli's email about the C modes.
> My emacs build is devoid of most of the settings and
> features, including GUI and tree-sitter (the config command is in
> the original report). So it is likely that only cc-mode is affected,
> and not c-ts-mode.
This is indeed the case.
> Note also that vulkan_core.h isn't special. A C source/header file
> with a long enough enum definition also works. Attached is a C
> program that generates to stdout the contents of such a header
> file. Opening the contents (after they are saved to a file by stdout
> redirection, etc.) in emacs demonstrates the problem.
The problem is long stretches of code (>= 500 characters) where there're
no statement boundaries or braces. These frequently occur in enums. An
ad hoc limit to 500 characters backward search is there for speed.
However, this bit of code was not checking whether it found a
brace/statement or hit the 500 char limit, hence the mis-fontification.
The patch below tries to fix this. Would you please apply it to
cc-mode.el (in .../lisp/progmodes), byte compile the result, and load it
into your Emacs (or restart Emacs). Then please try it out on the real
files that showed the bug. Please let me know if the bug really is
fixed. (If you want any help with patching or byte compiling, feel free
to send me private email.)
diff -r 709b797bdef8 cc-mode.el
--- a/cc-mode.el Tue Mar 26 20:26:16 2024 +0000
+++ b/cc-mode.el Sun Apr 14 02:39:32 2024 +0000
@@ -2437,7 +2437,7 @@
(backward-char)
(setq pseudo (c-cheap-inside-bracelist-p (c-parse-state)))))))
(goto-char pseudo))
- t)
+ pseudo)
;; Move forward to the start of the next declaration.
(progn (c-forward-syntactic-ws)
;; Have we got stuck in a comment at EOB?
> -Amol
> > Alan, would you please have a look?
--
Alan Mackenzie (Nuremberg, Germany).
next prev parent reply other threads:[~2024-04-14 2:46 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-13 12:42 bug#70367: 30.0.50; Inconsistent Syntax Highlighting Amol Surati
2024-04-13 17:44 ` Eli Zaretskii
2024-04-13 17:48 ` Eli Zaretskii
2024-04-13 19:00 ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-13 19:05 ` Eli Zaretskii
2024-04-13 22:14 ` Amol Surati
2024-04-14 2:46 ` Alan Mackenzie [this message]
2024-04-14 5:07 ` Amol Surati
2024-04-14 8:33 ` Alan Mackenzie
2024-04-13 19:14 ` Amol Surati
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZhtDgkpI2ITs0jIa@ACM \
--to=acm@muc.de \
--cc=70367@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=stephen.berman@gmx.net \
--cc=suratiamol@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).