bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#23501: Non-regex-based syntax highlighting


From: Nir Friedman
Subject: bug#23501: Non-regex-based syntax highlighting
Date: Tue, 10 May 2016 14:55:41 -0400

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 <address@hidden> wrote:
> From: Nir Friedman <address@hidden>
> 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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]