From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Amol Surati Newsgroups: gmane.emacs.bugs Subject: bug#70367: 30.0.50; Inconsistent Syntax Highlighting Date: Sun, 14 Apr 2024 10:37:32 +0530 Message-ID: References: <86r0f9nomy.fsf@gnu.org> <86plutnogj.fsf@gnu.org> <87bk6dozpb.fsf@gmx.net> <86le5hnkvh.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20917"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , Stephen Berman , 70367@debbugs.gnu.org To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Apr 14 08:58:38 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rvtoz-0005ER-Nx for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 14 Apr 2024 08:58:37 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rvtoN-0000Kc-WE; Sun, 14 Apr 2024 02:58:00 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rvtoK-0000JJ-W5 for bug-gnu-emacs@gnu.org; Sun, 14 Apr 2024 02:57:57 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rvtoK-0008MQ-NW for bug-gnu-emacs@gnu.org; Sun, 14 Apr 2024 02:57:56 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rvtoV-0000VE-K4 for bug-gnu-emacs@gnu.org; Sun, 14 Apr 2024 02:58:07 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Amol Surati Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 14 Apr 2024 06:58:07 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70367 X-GNU-PR-Package: emacs Original-Received: via spool by 70367-submit@debbugs.gnu.org id=B70367.17130778691696 (code B ref 70367); Sun, 14 Apr 2024 06:58:07 +0000 Original-Received: (at 70367) by debbugs.gnu.org; 14 Apr 2024 06:57:49 +0000 Original-Received: from localhost ([127.0.0.1]:34159 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rvto8-0000QZ-UK for submit@debbugs.gnu.org; Sun, 14 Apr 2024 02:57:48 -0400 Original-Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]:54365) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rvs5T-0000Ao-4m for 70367@debbugs.gnu.org; Sun, 14 Apr 2024 01:07:33 -0400 Original-Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2d895138ce6so24918021fa.0 for <70367@debbugs.gnu.org>; Sat, 13 Apr 2024 22:07:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713071234; x=1713676034; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=jM6RxmiEZs9XwI8pUMRb8qk1JMkYdvIHkMO+NZ6zwrU=; b=Ocr/Pl/QIjmsj4VeJFYo7QEQ6W7xofqqTzX7WioYEsFPtVGP80maxdh0mJVIi8vs+n 7sF29rvObishqjWX9p6PKijqN8KXFX3fuL9bDSc++UK2C24VqGGJNOOvc7aNMB01fdPX B7lyU5qXG7uIR2wTtlVhiOSviuUTf+4I17as/5MHTvqkwTbN13c+2IXrH0LbnUpQDU80 P85MgggFq61hoXlag5IuvX/a+a6lMXzQ5LbBwz+P7KMv3F2pm/Xh0wCYKQ50bSGWI+wO zO/rrL5eaZfjy/1HMs/YHmUDhuQ/wZmVHGxhMtAACXjqw2bGLIsVbPJB8blZcbc+awM4 bOLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713071234; x=1713676034; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=jM6RxmiEZs9XwI8pUMRb8qk1JMkYdvIHkMO+NZ6zwrU=; b=rOkKrKRt+MrYpyo228rjBUGyuHclF8lHhL2NmXTo0ZAdVOjL8fgmUmUHKYaAj3Ai4Z jLeq5iHq38Swjp5ltrz9EPXlGgj8eB2rPwbTV7HSD0lULv93qeCrOBvWLruELq6eDFKZ nZVibhjhyHZTOMYK6WE+nDuBkqgrXfpMlDtvsx5WIBDuzwWlKY1PNwRaJqrE6PIaVVj7 B820tb2GAVlzkS6UIYM9ZX4LJUc5yGWKMZ1ekHm+5GlX3ntlEv6vSofhlNbJ+NqXwTDJ nmWTN+dXkhrJ19rrXOI/+Mu8xDpVJcXjffI4KuTBXPZMXSZkJHSREEdcquhc7aB+MwNE Y0wg== X-Forwarded-Encrypted: i=1; AJvYcCUzMLadaXmLPGMKE/qyPPj6/Fp4bSm/jeNvJx2ScKMJsD3vLF8ai+XPQsClrVjlHWxkvWeB2J+7TU7pMIhbpJ8KzR5mEh0= X-Gm-Message-State: AOJu0YzRcAAQ2apkQksvs0cFEEx+nDyAgk1RGKCkneLVNs4wMc+Ja1lS h83zgRbi+FE7UB3Ip9a/S25Xgur55+UGmbf/tI+pEjc2zdZKlbXqrH5gOR4dVNVvzNcMf+tuRWz ptnpAuDixCxymAvHPfkrtXOyS5JA= X-Google-Smtp-Source: AGHT+IEHw40cKCA6wZFUxk09DHL3CPOzq9taclLIuRsgT6bkiCC+281Gmd9pZJnE2Sp09TWIiB96ngwMscKjVL/Rs7c= X-Received: by 2002:a2e:b753:0:b0:2d8:d972:67e0 with SMTP id k19-20020a2eb753000000b002d8d97267e0mr3928810ljo.10.1713071233844; Sat, 13 Apr 2024 22:07:13 -0700 (PDT) In-Reply-To: X-Mailman-Approved-At: Sun, 14 Apr 2024 02:57:35 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:283251 Archived-At: Hello, Alan. On Sun, 14 Apr 2024 at 08:16, Alan Mackenzie wrote: > > 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. Thank you for the kind words. > > On Sun, Apr 14, 2024 at 03:44:01 +0530, Amol Surati wrote: > > On Sun, 14 Apr 2024 at 00:35, Eli Zaretskii wrote: > > > > > From: Stephen Berman > > > > 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 wrote: > > > > > >> Cc: 70367@debbugs.gnu.org > > > > >> Date: Sat, 13 Apr 2024 20:44:37 +0300 > > > > >> From: Eli Zaretskii > > > > > >> > From: Amol Surati > > > > >> > 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. Understood. > > > 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. Consistent with the observed behaviour, that it is mostly enums that are affected. > > 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.) Thanks for the patch. It indeed fixes the highlighting problem on the real file vulkan_core.h (I know about only this one real file that's affected), as well as it does on the test file. -Amol > > > > 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).