all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Nir Friedman <quicknir@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 23501@debbugs.gnu.org
Subject: bug#23501: Non-regex-based syntax highlighting
Date: Tue, 10 May 2016 14:55:41 -0400	[thread overview]
Message-ID: <CA+cBnHBoLTUYQK+9JYPMkVqPfwunfWFhLJHfWUNT=Mqv2PMtSw@mail.gmail.com> (raw)
In-Reply-To: <834ma5dhut.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 2368 bytes --]

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 <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
> 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.
>

[-- Attachment #2: Type: text/html, Size: 2818 bytes --]

  reply	other threads:[~2016-05-10 18:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-10  3:12 bug#23501: Non-regex-based syntax highlighting Nir Friedman
2016-05-10 15:57 ` Richard Stallman
2016-05-10 15:59 ` Eli Zaretskii
2016-05-10 18:55   ` Nir Friedman [this message]
2016-05-10 19:21     ` Eli Zaretskii
2016-05-10 20:16       ` Nir Friedman
2016-05-11  7:49         ` Eli Zaretskii
2020-08-12  2:31           ` Stefan Kangas
2016-05-11 17:56         ` John Mastro

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CA+cBnHBoLTUYQK+9JYPMkVqPfwunfWFhLJHfWUNT=Mqv2PMtSw@mail.gmail.com' \
    --to=quicknir@gmail.com \
    --cc=23501@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.