From unknown Sat Aug 16 14:25:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#23501: Non-regex-based syntax highlighting Resent-From: Nir Friedman Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 10 May 2016 03:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 23501 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 23501@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.146285090132464 (code B ref -1); Tue, 10 May 2016 03:29:02 +0000 Received: (at submit) by debbugs.gnu.org; 10 May 2016 03:28:21 +0000 Received: from localhost ([127.0.0.1]:44976 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1azyLM-0008RY-IZ for submit@debbugs.gnu.org; Mon, 09 May 2016 23:28:20 -0400 Received: from eggs.gnu.org ([208.118.235.92]:43457) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1azy6p-00085n-IQ for submit@debbugs.gnu.org; Mon, 09 May 2016 23:13:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1azy6j-0000Kx-8H for submit@debbugs.gnu.org; Mon, 09 May 2016 23:13:14 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, HTML_MESSAGE,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:58110) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1azy6j-0000Kr-4m for submit@debbugs.gnu.org; Mon, 09 May 2016 23:13:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34420) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1azy6g-0007Jz-Ru for bug-gnu-emacs@gnu.org; Mon, 09 May 2016 23:13:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1azy6e-0000Jy-CD for bug-gnu-emacs@gnu.org; Mon, 09 May 2016 23:13:09 -0400 Received: from mail-ig0-x22d.google.com ([2607:f8b0:4001:c05::22d]:35442) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1azy6e-0000Ju-7A for bug-gnu-emacs@gnu.org; Mon, 09 May 2016 23:13:08 -0400 Received: by mail-ig0-x22d.google.com with SMTP id bi2so122249757igb.0 for ; Mon, 09 May 2016 20:13:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to; bh=jUw6wXjWh2yXCjjv6fU8MlkzHj/lBunpH/eakbueOKY=; b=YgIdRuq2mkIx7sSMdGGhCcVCZxnWmR/Pnnagm41uHyWTwJOdxt6fXEWTobBZG1D1s8 DZrK/ARmTH6HDRyecaBWburnXJBYbgfAQDajDoBYKTDN1mMWAyJERToQ1ubjrfwm8EBk 0sxsbpLOC2WwWQ4dAi600XGchBEoIYlsLsxIA2wkRqonQu38vkNoophCWO7agiBWOMi7 dRp/Ip5yBtq15R+KGoXJHiMc3oTtuLmNd6FSC4+dOh1Cm5n1E3snFSiqY1n629holdEF MHhFEUz/1sJ1ulPCbuyc2ZAqJmGbDadnoCu20eZ1VjkT5b9njGk3B96tj5dV8/w4V/yz 1unA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=jUw6wXjWh2yXCjjv6fU8MlkzHj/lBunpH/eakbueOKY=; b=NpvD7CIQaX63oHj4UBK5T2+vxW5l3f/5wHtNZKqY7rJ+Y53clInsXNG7EEek+7sEgt ud7TyR1evVCbgp7rm+cSsCUy8qiKPCbIzoHFW6whz4MPBsBeo6McbTSmVjvPPI4JOaCz VDoP/EAwh/piuolUBSrBimqukbHRB3uOD2g/0s9ENrPOB+mD+sco7iPtZmtfniC5Gq9h H6Uh8ruANL/N8hckwMnA/VTR/TszbMJE8RCbbzsbbmEFbv/pFnQDYbkqvAcV/zG9TtId DF1XZ3IDGs4IgDXyNgNTAX1V82TQ8vrT8gRl7Qaw03yp5gXyDV+tBsh7nakhXIYMQjB5 VgDQ== X-Gm-Message-State: AOPr4FXM2nR506RYbkwRSyZvRNLFJ2vNPaOfH8OS+6uUo9mIF8tolcV4nlqlb2xSIuCpqe9wG8RPgORZ8zaypg== X-Received: by 10.50.68.226 with SMTP id z2mr6770222igt.53.1462849987151; Mon, 09 May 2016 20:13:07 -0700 (PDT) MIME-Version: 1.0 Received: by 10.79.129.11 with HTTP; Mon, 9 May 2016 20:12:47 -0700 (PDT) From: Nir Friedman Date: Mon, 9 May 2016 23:12:47 -0400 Message-ID: Content-Type: multipart/alternative; boundary=089e01160fa0d810ef0532744d68 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Mailman-Approved-At: Mon, 09 May 2016 23:28:18 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) --089e01160fa0d810ef0532744d68 Content-Type: text/plain; charset=UTF-8 I'm considering using emacs as a platform for C++ development. One thing that seems to lag behind on emacs at the moment is that all of the syntax highlighting for C++ is (as far as I can tell) regex based. This severely limits the accuracy and discrimination that the syntax highlighter can achieve. There are now some packages for emacs that use a clang based backends to get actual AST information. Perhaps it would be possible to write some kind of hooks or template for major modes that would make it easier for package authors to change how syntax highlighting is performed in major modes? --089e01160fa0d810ef0532744d68 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I'm considering using emacs as a platform for C++ deve= lopment. One thing that seems to lag behind on emacs at the moment is that = all of the syntax highlighting for C++ is (as far as I can tell) regex base= d. This severely limits the accuracy and discrimination that the syntax hig= hlighter can achieve. There are now some packages for emacs that use a clan= g based backends to get actual AST information. Perhaps it would be possibl= e to write some kind of hooks or template for major modes that would make i= t easier for package authors to change how syntax highlighting is performed= in major modes?
--089e01160fa0d810ef0532744d68-- From unknown Sat Aug 16 14:25:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#23501: Non-regex-based syntax highlighting Resent-From: Richard Stallman Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 10 May 2016 15:58:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23501 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Nir Friedman Cc: 23501@debbugs.gnu.org Reply-To: rms@gnu.org Received: via spool by 23501-submit@debbugs.gnu.org id=B23501.14628958595110 (code B ref 23501); Tue, 10 May 2016 15:58:01 +0000 Received: (at 23501) by debbugs.gnu.org; 10 May 2016 15:57:39 +0000 Received: from localhost ([127.0.0.1]:46045 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b0A2V-0001KM-7p for submit@debbugs.gnu.org; Tue, 10 May 2016 11:57:39 -0400 Received: from eggs.gnu.org ([208.118.235.92]:36778) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b0A2T-0001Jo-Hy for 23501@debbugs.gnu.org; Tue, 10 May 2016 11:57:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b0A2K-0004Tr-BE for 23501@debbugs.gnu.org; Tue, 10 May 2016 11:57:32 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:32786) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0A2I-0004Si-NA; Tue, 10 May 2016 11:57:26 -0400 Received: from rms by fencepost.gnu.org with local (Exim 4.82) (envelope-from ) id 1b0A2H-0004jx-MY; Tue, 10 May 2016 11:57:25 -0400 Content-Type: text/plain; charset=Utf-8 From: Richard Stallman In-reply-to: (message from Nir Friedman on Mon, 9 May 2016 23:12:47 -0400) References: Message-Id: Date: Tue, 10 May 2016 11:57:25 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -7.1 (-------) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -7.1 (-------) [[[ To any NSA and FBI agents reading my email: please consider ]]] [[[ whether defending the US Constitution against all enemies, ]]] [[[ foreign or domestic, requires you to follow Snowden's example. ]]] We develop GCC as well as Emacs. To adopt a competitor to GCC as a "solition" would be self defeating. A proper solution is to extend GCC so that it does the necessary job. -- Dr Richard Stallman President, Free Software Foundation (gnu.org, fsf.org) Internet Hall-of-Famer (internethalloffame.org) Skype: No way! See stallman.org/skype.html. From unknown Sat Aug 16 14:25:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#23501: Non-regex-based syntax highlighting Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 10 May 2016 16:00:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23501 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Nir Friedman Cc: 23501@debbugs.gnu.org Reply-To: Eli Zaretskii Received: via spool by 23501-submit@debbugs.gnu.org id=B23501.14628959715336 (code B ref 23501); Tue, 10 May 2016 16:00:03 +0000 Received: (at 23501) by debbugs.gnu.org; 10 May 2016 15:59:31 +0000 Received: from localhost ([127.0.0.1]:46061 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b0A4J-0001O0-B7 for submit@debbugs.gnu.org; Tue, 10 May 2016 11:59:31 -0400 Received: from eggs.gnu.org ([208.118.235.92]:38157) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b0A4H-0001Nl-Gw for 23501@debbugs.gnu.org; Tue, 10 May 2016 11:59:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b0A47-0005Lm-OV for 23501@debbugs.gnu.org; Tue, 10 May 2016 11:59:24 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:32860) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0A47-0005Kt-M3; Tue, 10 May 2016 11:59:19 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:2789 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1b0A45-0007bC-N2; Tue, 10 May 2016 11:59:18 -0400 Date: Tue, 10 May 2016 18:59:22 +0300 Message-Id: <834ma5dhut.fsf@gnu.org> From: Eli Zaretskii In-reply-to: (message from Nir Friedman on Mon, 9 May 2016 23:12:47 -0400) References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -7.1 (-------) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -7.1 (-------) > From: Nir Friedman > Date: Mon, 9 May 2016 23:12:47 -0400 > > I'm considering using emacs as a platform for C++ development. One thing that seems to lag behind on > emacs at the moment is that all of the syntax highlighting for C++ is (as far as I can tell) regex based. This > severely limits the accuracy and discrimination that the syntax highlighter can achieve. There are now some > packages for emacs that use a clang based backends to get actual AST information. Perhaps it would be > possible to write some kind of hooks or template for major modes that would make it easier for package > authors to change how syntax highlighting is performed in major modes? Sorry, I don't think I really understand what is the complaint/issue you are raising here, and what solution would you like to suggest for those issues. Could you perhaps elaborate? A specific example where the current code doesn't work would be a good starting point. Thanks. From unknown Sat Aug 16 14:25:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#23501: Non-regex-based syntax highlighting Resent-From: Nir Friedman Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 10 May 2016 18:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23501 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: 23501@debbugs.gnu.org Received: via spool by 23501-submit@debbugs.gnu.org id=B23501.146290656921582 (code B ref 23501); Tue, 10 May 2016 18:57:02 +0000 Received: (at 23501) by debbugs.gnu.org; 10 May 2016 18:56:09 +0000 Received: from localhost ([127.0.0.1]:46196 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b0CpF-0005c2-6r for submit@debbugs.gnu.org; Tue, 10 May 2016 14:56:09 -0400 Received: from mail-ig0-f174.google.com ([209.85.213.174]:35172) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b0CpD-0005bc-KV for 23501@debbugs.gnu.org; Tue, 10 May 2016 14:56:08 -0400 Received: by mail-ig0-f174.google.com with SMTP id bi2so140098331igb.0 for <23501@debbugs.gnu.org>; Tue, 10 May 2016 11:56:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=tDUxBZV89daIyzzbeL/pblzr0wBDaZCqXClWemtAddc=; b=h+JdxsSpVJAWscnE9HKAEzmOKLx8qRrzjtum5twW5CsSGT33aji1lAAhnCeqPCE16r ao2Ebx82Nz7I7wnF90BN11+yTu6FS36EDAom0G2yfwLe1PE6swotHkwKakmpJRUjgTFJ pbbWmU4W+fXpPQ63hQa/x0LziOVRccGJeAkzmK2qC+9HhH87VWU/TIBg80EhxDCK6+zz K8JQmMbujouT40QD1lnjtnj6Ige9bbPiE7uMj5cBuMgKHpRM1Tl/S4Gb2Mz6/CIUXU7i WjY/46l66fhzYaSrbQeV8A8A3SWvrMPs1JzNq37pgrEdrLx9hZ9fdOXbEN4a7n2Bg9A8 6JDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=tDUxBZV89daIyzzbeL/pblzr0wBDaZCqXClWemtAddc=; b=Fj/frwtlVT+QgNe0xfi0qiWk3BTWNmuvuONMtv6kodHZtVjkoE9c6tGgvYtcXyndJc Ikn8S7/ro06D0FHxxbC1VWthVzkm8augKQQKM9qNe7P1EDpPEpBJm48tEBJIWn4QUis5 /FMZmQZIuGBhHrvQtxb/1Ar9jzxuaBXxKkaxum86psDpaPAceq2wiCVP+YY9y0AsyKKp esdhLxB9Uu/vqZlWhSeUUT3S9pa8AQmmGFGS/RzjkT0jcBVr6GPsZvFhujwiYYASXllQ msD8uY9LAHfFpOsotRtQllXtuVql4KBwK8O6SPqLovEiEyBxmSuFKkQknqAW7rUP/Bs0 v8Aw== X-Gm-Message-State: AOPr4FW8173TeWGQ8sItu8MDVgXpIs1MqwK4GDGLUcFLXijb+f7qrxd/xAuvnXXg9MCEz/U5lNY5DA+s1i97Pw== X-Received: by 10.50.49.15 with SMTP id q15mr17922234ign.73.1462906561309; Tue, 10 May 2016 11:56:01 -0700 (PDT) MIME-Version: 1.0 Received: by 10.79.129.11 with HTTP; Tue, 10 May 2016 11:55:41 -0700 (PDT) In-Reply-To: <834ma5dhut.fsf@gnu.org> References: <834ma5dhut.fsf@gnu.org> From: Nir Friedman Date: Tue, 10 May 2016 14:55:41 -0400 Message-ID: Content-Type: multipart/alternative; boundary=e89a8f64694fed354c053281798c X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) --e89a8f64694fed354c053281798c Content-Type: text/plain; charset=UTF-8 For instance, suppose I write some C++ that looks like this: using MyType = Something::OtherType; There's no way to determine locally whether Something is a namespace or itself a type, so a regex based syntax highlighter cannot consistently color namespaces and classes differently. To take one example, Eclipse will perform this determination and will consistently color namespaces and classes any color you like. It can do this because it parses the code and uses the AST. It makes many more useful distinctions which cannot be made locally; for example when calling a function foo from a member function bar of an object, there is no way to easily tell whether foo is also a member of the same object as bar, or whether foo is just a free function in the same namespace. One has privileged access and the other probably doesn't, so it's a genuinely useful distinction. I guess I'm a bit less clear on the solution, because I don't have a good sense of who the owner of the C++ major mode is, and how the code is structured. My thinking was that perhaps hooks could be added to make it easier for plugin writers to modify the syntax coloring of the major mode. As opposed to plugin writers needing to rewrite the C++ major mode from scratch just to change the syntax coloring. On Tue, May 10, 2016 at 11:59 AM, Eli Zaretskii wrote: > > From: Nir Friedman > > Date: Mon, 9 May 2016 23:12:47 -0400 > > > > I'm considering using emacs as a platform for C++ development. One thing > that seems to lag behind on > > emacs at the moment is that all of the syntax highlighting for C++ is > (as far as I can tell) regex based. This > > severely limits the accuracy and discrimination that the syntax > highlighter can achieve. There are now some > > packages for emacs that use a clang based backends to get actual AST > information. Perhaps it would be > > possible to write some kind of hooks or template for major modes that > would make it easier for package > > authors to change how syntax highlighting is performed in major modes? > > Sorry, I don't think I really understand what is the complaint/issue > you are raising here, and what solution would you like to suggest for > those issues. Could you perhaps elaborate? A specific example where > the current code doesn't work would be a good starting point. > > Thanks. > --e89a8f64694fed354c053281798c Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
For instance, suppose I write some C++ that looks like thi= s:

using MyType =3D Something::OtherType;

There's no way = to determine locally whether Something is a namespace or itself a type, so = a regex based syntax highlighter cannot consistently color namespaces and c= lasses differently. To take one example, Eclipse will perform this determin= ation and will consistently color namespaces and classes any color you like= . It can do this because it parses the code and uses the AST. It makes many= more useful distinctions which cannot be made locally; for example when ca= lling a function foo from a member function bar of an object, there is no w= ay to easily tell whether foo is also a member of the same object as bar, o= r whether foo is just a free function in the same namespace. One has privil= eged access and the other probably doesn't, so it's a genuinely use= ful distinction.

I guess I'm a bit less clear on the solution, b= ecause I don't have a good sense of who the owner of the C++ major mode= is, and how the code is structured. My thinking was that perhaps hooks cou= ld be added to make it easier for plugin writers to modify the syntax color= ing of the major mode. As opposed to plugin writers needing to rewrite the = C++ major mode from scratch just to change the syntax coloring.

On Tue, May 10, 2016 at= 11:59 AM, Eli Zaretskii <eliz@gnu.org> wrote:
> From: Nir Friedman <quicknir@gmail.com>
> Date: Mon, 9 May 2016 23:12:47 -0400
>
> I'm considering using emacs as a platform for C++ development. One= thing that seems to lag behind on
> emacs at the moment is that all of the syntax highlighting for C++ is = (as far as I can tell) regex based. This
> severely limits the accuracy and discrimination that the syntax highli= ghter can achieve. There are now some
> packages for emacs that use a clang based backends to get actual AST i= nformation. Perhaps it would be
> possible to write some kind of hooks or template for major modes that = would make it easier for package
> authors to change how syntax highlighting is performed in major modes?=

Sorry, I don't think I really understand what is the complaint/issue you are raising here, and what solution would you like to suggest for
those issues.=C2=A0 Could you perhaps elaborate?=C2=A0 A specific example w= here
the current code doesn't work would be a good starting point.

Thanks.

--e89a8f64694fed354c053281798c-- From unknown Sat Aug 16 14:25:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#23501: Non-regex-based syntax highlighting Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 10 May 2016 19:22:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23501 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Nir Friedman Cc: 23501@debbugs.gnu.org Reply-To: Eli Zaretskii Received: via spool by 23501-submit@debbugs.gnu.org id=B23501.146290810124146 (code B ref 23501); Tue, 10 May 2016 19:22:02 +0000 Received: (at 23501) by debbugs.gnu.org; 10 May 2016 19:21:41 +0000 Received: from localhost ([127.0.0.1]:46248 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b0DDw-0006HO-Pq for submit@debbugs.gnu.org; Tue, 10 May 2016 15:21:40 -0400 Received: from eggs.gnu.org ([208.118.235.92]:39029) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b0DDv-0006HC-QR for 23501@debbugs.gnu.org; Tue, 10 May 2016 15:21:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b0DDn-00087w-PL for 23501@debbugs.gnu.org; Tue, 10 May 2016 15:21:34 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:36687) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0DDn-00087m-M5; Tue, 10 May 2016 15:21:31 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:3842 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1b0DDl-0006Cx-SM; Tue, 10 May 2016 15:21:30 -0400 Date: Tue, 10 May 2016 22:21:35 +0300 Message-Id: <83vb2lbtxc.fsf@gnu.org> From: Eli Zaretskii In-reply-to: (message from Nir Friedman on Tue, 10 May 2016 14:55:41 -0400) References: <834ma5dhut.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -7.1 (-------) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -7.1 (-------) > From: Nir Friedman > Date: Tue, 10 May 2016 14:55:41 -0400 > Cc: 23501@debbugs.gnu.org > > I guess I'm a bit less clear on the solution, because I don't have a good sense of who the owner of the C++ > major mode is, and how the code is structured. My thinking was that perhaps hooks could be added to make > it easier for plugin writers to modify the syntax coloring of the major mode. As opposed to plugin writers > needing to rewrite the C++ major mode from scratch just to change the syntax coloring. Colors are added at display time, so hooks will not help here. Or at least it isn't immediately clear to me how they could help. I suggest to study how syntax highlighting works in Emacs, including the JIT font-lock feature and its relation to the display engine. Until you have a good understanding of how this stuff works, I don't think you will be able to come with a design for hooks which external tools could use for this purpose. From unknown Sat Aug 16 14:25:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#23501: Non-regex-based syntax highlighting Resent-From: Nir Friedman Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 10 May 2016 20:17:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23501 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: 23501@debbugs.gnu.org Received: via spool by 23501-submit@debbugs.gnu.org id=B23501.146291139129088 (code B ref 23501); Tue, 10 May 2016 20:17:01 +0000 Received: (at 23501) by debbugs.gnu.org; 10 May 2016 20:16:31 +0000 Received: from localhost ([127.0.0.1]:46291 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b0E50-0007Z6-Pg for submit@debbugs.gnu.org; Tue, 10 May 2016 16:16:31 -0400 Received: from mail-io0-f179.google.com ([209.85.223.179]:33924) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b0E4y-0007Yt-KM for 23501@debbugs.gnu.org; Tue, 10 May 2016 16:16:29 -0400 Received: by mail-io0-f179.google.com with SMTP id 190so30157157iow.1 for <23501@debbugs.gnu.org>; Tue, 10 May 2016 13:16:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=c/8AYhQs3YdA5pLtvoVSYpZObINaPRWuMXu967INrVw=; b=E0yJeqICwV6dV7/e94nDiI+6b9pIjDYn41ftMNWVr30LxNpV1sv4ZaTlcp+HTB8Kn5 Cb69cHuI7JJe6A9dIPRykJ6wBsPNU3XV7aG9JSXHkeosA7bVK9hOGbIVybP+I9bH2Y20 TysFMw6jaKGgHtFaNzEdDwLRBOuAaVlL/Kq8JPM+FDXwT8jIg8XOZ+qZG8M6D7h0U6ak 6nJpSviPHxq4dldPj4qIBbiPMf/+u4bc/hmG/jqnnpTV0mZu4cbNQ30LzqiXj3hrUzCV +ROPLg8v4GcZT4kFm/p8fwtHZ7UamGact2kSNwydj2dI1uYTLXI+PR2MoPZYMEJDYQq9 p9rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=c/8AYhQs3YdA5pLtvoVSYpZObINaPRWuMXu967INrVw=; b=kuY1YmmWJcUB4XUybBmsZpf8wI7p4qAk4hPE+LXAJZabxtyfyP177GQNG7q5+Crb6w qeyOf5Cl1kN8Pb/WDU3hnKZdZHhf92xG4uc6Z0yJNjF32OLPD3sleWBxSc2IgOIKgdnY 3Ecs8SVMMubS92xOBoT8u53zCzholyU7yQoKIHTF+/8rMWH6XTiLHFEXr2kOJ5azGFEd H8mFarilAYDB9U92Mq0/NiumK8jpEa7RP3VEYswhJNRXrWaWKUds2lVAjB0jPapby8o/ 8sTc+bTYTo81a82bZSlFL22AIQGUZioVrJIP6IFM18WU7ZqzLgTj3EduJRPJPXYYKrFY NZYg== X-Gm-Message-State: AOPr4FWrfafWLNcxLnHALuWsWenLlNRrbUE3A/fehfKWS8hERyYEjC2nk3YZExAbqDHT0PEa7W0j6sGYzSo5vw== X-Received: by 10.36.13.76 with SMTP id 73mr11378itx.87.1462911382787; Tue, 10 May 2016 13:16:22 -0700 (PDT) MIME-Version: 1.0 Received: by 10.79.129.11 with HTTP; Tue, 10 May 2016 13:16:03 -0700 (PDT) In-Reply-To: <83vb2lbtxc.fsf@gnu.org> References: <834ma5dhut.fsf@gnu.org> <83vb2lbtxc.fsf@gnu.org> From: Nir Friedman Date: Tue, 10 May 2016 16:16:03 -0400 Message-ID: Content-Type: multipart/alternative; boundary=001a113f63d64f3148053282994f X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) --001a113f63d64f3148053282994f Content-Type: text/plain; charset=UTF-8 My idea for a hook was basically to make it possible to provide a callback function to the Major mode. If this callback function is provided, then when a new file is loaded or an existing one saved with modifications, the callback function is called with the full path to the file. The callback function must return something that basically tells the major mode how to color everything. A simple way would just be to return a list of the colors for every single non-whitespace character taken sequentially. A single very fast pass through this list would then be able to color every character. Is there a reason why that would not be workable? Also, can you point me to where exactly (e.g. via link to the emacs github mirror) the major modes are stored? On Tue, May 10, 2016 at 3:21 PM, Eli Zaretskii wrote: > > From: Nir Friedman > > Date: Tue, 10 May 2016 14:55:41 -0400 > > Cc: 23501@debbugs.gnu.org > > > > I guess I'm a bit less clear on the solution, because I don't have a > good sense of who the owner of the C++ > > major mode is, and how the code is structured. My thinking was that > perhaps hooks could be added to make > > it easier for plugin writers to modify the syntax coloring of the major > mode. As opposed to plugin writers > > needing to rewrite the C++ major mode from scratch just to change the > syntax coloring. > > Colors are added at display time, so hooks will not help here. Or at > least it isn't immediately clear to me how they could help. > > I suggest to study how syntax highlighting works in Emacs, including > the JIT font-lock feature and its relation to the display engine. > Until you have a good understanding of how this stuff works, I don't > think you will be able to come with a design for hooks which external > tools could use for this purpose. > --001a113f63d64f3148053282994f Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
My idea for a hook was basically to make it possible to pr= ovide a callback function to the Major mode. If this callback function is p= rovided, then when a new file is loaded or an existing one saved with modif= ications, the callback function is called with the full path to the file. T= he callback function must return something that basically tells the major m= ode how to color everything. A simple way would just be to return a list of= the colors for every single non-whitespace character taken sequentially. A= single very fast pass through this list would then be able to color every = character.

Is there a reason why that would not be worka= ble? Also, can you point me to where exactly (e.g. via link to the emacs gi= thub mirror) the major modes are stored?


<= /div>

On Tue= , May 10, 2016 at 3:21 PM, Eli Zaretskii <eliz@gnu.org> wrote:
> From: Nir Friedman <quicknir@gmail.com>
> Date: Tue, 10 May 2016 14:55:41 -0400
> Cc: 23501@debbugs.gnu.org=
>
> I guess I'm a bit less clear on the solution, because I don't = have a good sense of who the owner of the C++
> major mode is, and how the code is structured. My thinking was that pe= rhaps hooks could be added to make
> it easier for plugin writers to modify the syntax coloring of the majo= r mode. As opposed to plugin writers
> needing to rewrite the C++ major mode from scratch just to change the = syntax coloring.

Colors are added at display time, so hooks will not help here.=C2=A0= Or at
least it isn't immediately clear to me how they could help.

I suggest to study how syntax highlighting works in Emacs, including
the JIT font-lock feature and its relation to the display engine.
Until you have a good understanding of how this stuff works, I don't think you will be able to come with a design for hooks which external
tools could use for this purpose.

--001a113f63d64f3148053282994f-- From unknown Sat Aug 16 14:25:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#23501: Non-regex-based syntax highlighting Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 11 May 2016 07:50:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23501 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Nir Friedman Cc: 23501@debbugs.gnu.org Reply-To: Eli Zaretskii Received: via spool by 23501-submit@debbugs.gnu.org id=B23501.146295298225063 (code B ref 23501); Wed, 11 May 2016 07:50:02 +0000 Received: (at 23501) by debbugs.gnu.org; 11 May 2016 07:49:42 +0000 Received: from localhost ([127.0.0.1]:46622 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b0Otp-0006WB-QE for submit@debbugs.gnu.org; Wed, 11 May 2016 03:49:41 -0400 Received: from eggs.gnu.org ([208.118.235.92]:42798) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b0Oto-0006Vy-5o for 23501@debbugs.gnu.org; Wed, 11 May 2016 03:49:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b0Otd-0003sD-W1 for 23501@debbugs.gnu.org; Wed, 11 May 2016 03:49:34 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:47422) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0Otd-0003s2-ST; Wed, 11 May 2016 03:49:29 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:4555 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1b0Otb-0004Lk-MN; Wed, 11 May 2016 03:49:28 -0400 Date: Wed, 11 May 2016 10:49:34 +0300 Message-Id: <83r3d9avap.fsf@gnu.org> From: Eli Zaretskii In-reply-to: (message from Nir Friedman on Tue, 10 May 2016 16:16:03 -0400) References: <834ma5dhut.fsf@gnu.org> <83vb2lbtxc.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -7.1 (-------) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -7.1 (-------) > From: Nir Friedman > Date: Tue, 10 May 2016 16:16:03 -0400 > Cc: 23501@debbugs.gnu.org > > My idea for a hook was basically to make it possible to provide a callback function to the Major mode. If this > callback function is provided, then when a new file is loaded or an existing one saved with modifications, the > callback function is called with the full path to the file. The syntax highlighting should change also when you modify the buffer, not only when you save it. How will that work with your proposed hook? > The callback function must return something that > basically tells the major mode how to color everything. A simple way would just be to return a list of the colors > for every single non-whitespace character taken sequentially. A single very fast pass through this list would > then be able to color every character. The hook cannot return a color, because the colors are defined via faces. It should return faces instead. > Is there a reason why that would not be workable? Maybe it is workable, but you are missing too many details of how syntax highlight works in Emacs. As I wrote previously, I encourage you to study how that works, in order for the proposal to be workable and practical. > Also, can you point me to where exactly (e.g. via link to the > emacs github mirror) the major modes are stored? It's not the major mode that you need to look at, it's the font-lock machinery. Major modes just use the font-lock features by setting the font-lock faces on portions of the buffer. Then at display time, the visible portion of the buffer are displayed as specified by those faces. You will see that each major mode simply sets the font-lock faces, and leaves the rest to the core features. See font-lock.el and font-core.el for the font-lock features, and jit-lock.el for the JIT coloring of the visible portions of the buffer. From unknown Sat Aug 16 14:25:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#23501: Non-regex-based syntax highlighting Resent-From: John Mastro Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 11 May 2016 17:57:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23501 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 23501@debbugs.gnu.org Cc: Nir Friedman , Eli Zaretskii Received: via spool by 23501-submit@debbugs.gnu.org id=B23501.146298941925504 (code B ref 23501); Wed, 11 May 2016 17:57:01 +0000 Received: (at 23501) by debbugs.gnu.org; 11 May 2016 17:56:59 +0000 Received: from localhost ([127.0.0.1]:47609 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b0YNW-0006dI-TW for submit@debbugs.gnu.org; Wed, 11 May 2016 13:56:59 -0400 Received: from mail-yw0-f171.google.com ([209.85.161.171]:36859) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b0YNV-0006cy-By for 23501@debbugs.gnu.org; Wed, 11 May 2016 13:56:57 -0400 Received: by mail-yw0-f171.google.com with SMTP id o66so56264824ywc.3 for <23501@debbugs.gnu.org>; Wed, 11 May 2016 10:56:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=kTo3xBhvuFyckXZcRvfWHaOCSkkyGWlnZMAWlCU4Xp4=; b=0FNVKRg8o8mVZKC2wdoMgNkGAHKlbrGbYeVvvrJp2IC6U68/A7QbBbHJ/+V7pcWEvL rs6xmdsMfrypGCI4/0qgzn4j9zmCBIvXqn6vm2dt8/wbNlSLki+0WgjDPbmcKZZX1IDs 1o5wNPgLJG6RI96J8bX5IfTrsQsMfDtc+OoA/09RiE1sVlkq1AC6F/FpYtvCnyrEktHC 5x4EUit9raGmpfdI2WpbnnrOxxKSNXLNIXWqYUynbb3GB4XEsXMyuYzMadM/wp2yFR2b WN0WPzo4nd2uOXfYgCjESu6f7b4+CnkAuSi4P0fYUeQOkIflPJ6Xisp4QhSBz0DsCTKu zS5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=kTo3xBhvuFyckXZcRvfWHaOCSkkyGWlnZMAWlCU4Xp4=; b=HKsjY9sW9/0AUnDEoDvrr+0M6CSGt6NLUxZw6rvtx0shyxVhjjH/FWyfHPsCocURMf fVBLbjTWAkbMyCAy/B4UGBq/LuHMkBjZCs2/9J+s8b1+CEgDweB2qKohD9+5zUoGz1Q5 PYcwZ0S7uUrdinbprpa8XC/6buuhou0+g4wK+SPmrd8Kpw3GCOLcPytoc6rxQmZY+6ec QcvfXi4BuSGNrULFErBJtkuljLsvAoEkxM5HXE1V+1NM7Hn+NpJ9DLxvSmPTItTr1bco VCC8t7yQIPhO4aDImQQhhoWOAOc82bH9Fs4aCV8zx2w9zf/v7NckiHKCL8zBh2lvqF0D XjMw== X-Gm-Message-State: AOPr4FVsEO+Jdh5riVqEmq+PfrhGn3rCW7au+bmjDwV6nmbVKcaQ4MfqLESLuV7DWoqIe5rdwARzzUj6yrxahQ== X-Received: by 10.129.106.196 with SMTP id f187mr2284697ywc.262.1462989411430; Wed, 11 May 2016 10:56:51 -0700 (PDT) MIME-Version: 1.0 Received: by 10.37.98.81 with HTTP; Wed, 11 May 2016 10:56:32 -0700 (PDT) In-Reply-To: References: <834ma5dhut.fsf@gnu.org> <83vb2lbtxc.fsf@gnu.org> From: John Mastro Date: Wed, 11 May 2016 10:56:32 -0700 Message-ID: Content-Type: text/plain; charset=UTF-8 X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Nir Friedman wrote: > Is there a reason why that would not be workable? Also, can you point me to > where exactly (e.g. via link to the emacs github mirror) the major modes are > stored? To find a particular major mode (or other library), you can use `find-library'. For instance, try `M-x find-library RET cc-mode RET' and `M-x find-library RET font-lock RET'. -- john From unknown Sat Aug 16 14:25:46 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Nir Friedman Subject: bug#23501: closed (Re: bug#23501: Non-regex-based syntax highlighting) Message-ID: References: X-Gnu-PR-Message: they-closed 23501 X-Gnu-PR-Package: emacs Reply-To: 23501@debbugs.gnu.org Date: Wed, 12 Aug 2020 02:32:03 +0000 Content-Type: multipart/mixed; boundary="----------=_1597199523-6197-1" This is a multi-part message in MIME format... ------------=_1597199523-6197-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #23501: Non-regex-based syntax highlighting which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 23501@debbugs.gnu.org. --=20 23501: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D23501 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1597199523-6197-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 23501-done) by debbugs.gnu.org; 12 Aug 2020 02:31:18 +0000 Received: from localhost ([127.0.0.1]:42319 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k5gXu-0001aa-6a for submit@debbugs.gnu.org; Tue, 11 Aug 2020 22:31:18 -0400 Received: from mail-yb1-f194.google.com ([209.85.219.194]:32948) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k5gXp-0001a6-4F for 23501-done@debbugs.gnu.org; Tue, 11 Aug 2020 22:31:16 -0400 Received: by mail-yb1-f194.google.com with SMTP id p191so571320ybg.0 for <23501-done@debbugs.gnu.org>; Tue, 11 Aug 2020 19:31:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:in-reply-to:references:user-agent :mime-version:date:message-id:subject:to:cc; bh=o/Xb3Yw/mjUdKjKqD1TK2n9Mu4dCUa/mUIni55a8hkY=; b=CBX7DK9r86okhfbDDjpYuYx4amiVPPaMBKpm6nxUYLH/OIcbAXhYJhomQ/JBifbvbF 3kIr/x19l9ZH4Dk5pxCvV7dZslTVfHGtmmEIfuc+tITIqD15ea8b0Omf9dcAJfa0giIl U98PXgkVS0GrupI/k7uiFQiPCHUxnbdPsDGmHth5GK8VPhdvn99qeopPJFiGzm5nR6b0 QRWxRg4azb1aR03iYBc6GVpMsKi4pkzRrV6UmVFmztR0qvwU89f6YGWCKkdCdJr2lDiW bX/6gzRrRYR5D95ZhLHSnfP+ehjcVVsLuQXZTPL1KW542zawCUW8subFOAX3PCyz+4g3 5+uQ== X-Gm-Message-State: AOAM530hdNbQhVryqFB6ry/wbVa3PonjEUSeloUtVChUFZWJH2k2cj/n G6JR4lAVJFp/K2XI1j8fmaguiXOvReXVbknuESs= X-Google-Smtp-Source: ABdhPJy+ok0f/RKGHhMhKDpZDg62vCY1VYwSadrMz/tR4Cw/4S3AGXNrWbKi681H9qp0PG6o/pJDdCqxmt6GVSH+/pI= X-Received: by 2002:a25:9843:: with SMTP id k3mr52690666ybo.466.1597199467691; Tue, 11 Aug 2020 19:31:07 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Tue, 11 Aug 2020 19:31:07 -0700 From: Stefan Kangas In-Reply-To: <83r3d9avap.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 11 May 2016 10:49:34 +0300") References: <834ma5dhut.fsf@gnu.org> <83vb2lbtxc.fsf@gnu.org> <83r3d9avap.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Date: Tue, 11 Aug 2020 19:31:07 -0700 Message-ID: Subject: Re: bug#23501: Non-regex-based syntax highlighting To: Eli Zaretskii Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 23501-done Cc: Nir Friedman , 23501-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eli Zaretskii writes: >> From: Nir Friedman >> Date: Tue, 10 May 2016 16:16:03 -0400 >> Cc: 23501@debbugs.gnu.org >> >> My idea for a hook was basically to make it possible to provide a callback function to the Major mode. If this >> callback function is provided, then when a new file is loaded or an existing one saved with modifications, the >> callback function is called with the full path to the file. > > The syntax highlighting should change also when you modify the buffer, > not only when you save it. How will that work with your proposed hook? > >> The callback function must return something that >> basically tells the major mode how to color everything. A simple way would just be to return a list of the colors >> for every single non-whitespace character taken sequentially. A single very fast pass through this list would >> then be able to color every character. > > The hook cannot return a color, because the colors are defined via > faces. It should return faces instead. > >> Is there a reason why that would not be workable? > > Maybe it is workable, but you are missing too many details of how > syntax highlight works in Emacs. As I wrote previously, I encourage > you to study how that works, in order for the proposal to be workable > and practical. > >> Also, can you point me to where exactly (e.g. via link to the >> emacs github mirror) the major modes are stored? > > It's not the major mode that you need to look at, it's the font-lock > machinery. Major modes just use the font-lock features by setting the > font-lock faces on portions of the buffer. Then at display time, the > visible portion of the buffer are displayed as specified by those > faces. You will see that each major mode simply sets the font-lock > faces, and leaves the rest to the core features. > > See font-lock.el and font-core.el for the font-lock features, and > jit-lock.el for the JIT coloring of the visible portions of the > buffer. It seems like there was a proposal here 4 years ago, that Eli said was unworkable. There were also some outstanding questions regarding said proposal. But there were no further updates after that. I'm therefore closing this bug report now. If anyone wants to continue working on something along these lines, feel free to reopen this bug report or file a new one. Thanks. Best regards, Stefan Kangas ------------=_1597199523-6197-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 10 May 2016 03:28:21 +0000 Received: from localhost ([127.0.0.1]:44976 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1azyLM-0008RY-IZ for submit@debbugs.gnu.org; Mon, 09 May 2016 23:28:20 -0400 Received: from eggs.gnu.org ([208.118.235.92]:43457) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1azy6p-00085n-IQ for submit@debbugs.gnu.org; Mon, 09 May 2016 23:13:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1azy6j-0000Kx-8H for submit@debbugs.gnu.org; Mon, 09 May 2016 23:13:14 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, HTML_MESSAGE,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:58110) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1azy6j-0000Kr-4m for submit@debbugs.gnu.org; Mon, 09 May 2016 23:13:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34420) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1azy6g-0007Jz-Ru for bug-gnu-emacs@gnu.org; Mon, 09 May 2016 23:13:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1azy6e-0000Jy-CD for bug-gnu-emacs@gnu.org; Mon, 09 May 2016 23:13:09 -0400 Received: from mail-ig0-x22d.google.com ([2607:f8b0:4001:c05::22d]:35442) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1azy6e-0000Ju-7A for bug-gnu-emacs@gnu.org; Mon, 09 May 2016 23:13:08 -0400 Received: by mail-ig0-x22d.google.com with SMTP id bi2so122249757igb.0 for ; Mon, 09 May 2016 20:13:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to; bh=jUw6wXjWh2yXCjjv6fU8MlkzHj/lBunpH/eakbueOKY=; b=YgIdRuq2mkIx7sSMdGGhCcVCZxnWmR/Pnnagm41uHyWTwJOdxt6fXEWTobBZG1D1s8 DZrK/ARmTH6HDRyecaBWburnXJBYbgfAQDajDoBYKTDN1mMWAyJERToQ1ubjrfwm8EBk 0sxsbpLOC2WwWQ4dAi600XGchBEoIYlsLsxIA2wkRqonQu38vkNoophCWO7agiBWOMi7 dRp/Ip5yBtq15R+KGoXJHiMc3oTtuLmNd6FSC4+dOh1Cm5n1E3snFSiqY1n629holdEF MHhFEUz/1sJ1ulPCbuyc2ZAqJmGbDadnoCu20eZ1VjkT5b9njGk3B96tj5dV8/w4V/yz 1unA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=jUw6wXjWh2yXCjjv6fU8MlkzHj/lBunpH/eakbueOKY=; b=NpvD7CIQaX63oHj4UBK5T2+vxW5l3f/5wHtNZKqY7rJ+Y53clInsXNG7EEek+7sEgt ud7TyR1evVCbgp7rm+cSsCUy8qiKPCbIzoHFW6whz4MPBsBeo6McbTSmVjvPPI4JOaCz VDoP/EAwh/piuolUBSrBimqukbHRB3uOD2g/0s9ENrPOB+mD+sco7iPtZmtfniC5Gq9h H6Uh8ruANL/N8hckwMnA/VTR/TszbMJE8RCbbzsbbmEFbv/pFnQDYbkqvAcV/zG9TtId DF1XZ3IDGs4IgDXyNgNTAX1V82TQ8vrT8gRl7Qaw03yp5gXyDV+tBsh7nakhXIYMQjB5 VgDQ== X-Gm-Message-State: AOPr4FXM2nR506RYbkwRSyZvRNLFJ2vNPaOfH8OS+6uUo9mIF8tolcV4nlqlb2xSIuCpqe9wG8RPgORZ8zaypg== X-Received: by 10.50.68.226 with SMTP id z2mr6770222igt.53.1462849987151; Mon, 09 May 2016 20:13:07 -0700 (PDT) MIME-Version: 1.0 Received: by 10.79.129.11 with HTTP; Mon, 9 May 2016 20:12:47 -0700 (PDT) From: Nir Friedman Date: Mon, 9 May 2016 23:12:47 -0400 Message-ID: Subject: Non-regex-based syntax highlighting To: bug-gnu-emacs@gnu.org Content-Type: multipart/alternative; boundary=089e01160fa0d810ef0532744d68 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Mon, 09 May 2016 23:28:18 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) --089e01160fa0d810ef0532744d68 Content-Type: text/plain; charset=UTF-8 I'm considering using emacs as a platform for C++ development. One thing that seems to lag behind on emacs at the moment is that all of the syntax highlighting for C++ is (as far as I can tell) regex based. This severely limits the accuracy and discrimination that the syntax highlighter can achieve. There are now some packages for emacs that use a clang based backends to get actual AST information. Perhaps it would be possible to write some kind of hooks or template for major modes that would make it easier for package authors to change how syntax highlighting is performed in major modes? --089e01160fa0d810ef0532744d68 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I'm considering using emacs as a platform for C++ deve= lopment. One thing that seems to lag behind on emacs at the moment is that = all of the syntax highlighting for C++ is (as far as I can tell) regex base= d. This severely limits the accuracy and discrimination that the syntax hig= hlighter can achieve. There are now some packages for emacs that use a clan= g based backends to get actual AST information. Perhaps it would be possibl= e to write some kind of hooks or template for major modes that would make i= t easier for package authors to change how syntax highlighting is performed= in major modes?
--089e01160fa0d810ef0532744d68-- ------------=_1597199523-6197-1--