GNU bug report logs - #60087
29.0.60; c++-ts-mode conflict with electric-pair-mode

Previous Next

Package: emacs;

Reported by: Eason Huang <aqua0210 <at> foxmail.com>

Date: Thu, 15 Dec 2022 11:34:02 UTC

Severity: normal

Found in version 29.0.60

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: João Távora <joaotavora <at> gmail.com>
To: Daniel Martín <mardani29 <at> yahoo.es>,  Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Eason Huang <aqua0210 <at> foxmail.com>, casouri <at> gmail.com, 60087 <at> debbugs.gnu.org
Subject: bug#60087: 29.0.60; c++-ts-mode conflict with electric-pair-mode
Date: Thu, 15 Dec 2022 21:43:19 +0000
[Message part 1 (text/plain, inline)]
On Thu, Dec 15, 2022 at 9:34 PM Daniel Martín <mardani29 <at> yahoo.es> wrote:
>
> João Távora <joaotavora <at> gmail.com> writes:
>
> > I don't know how this can work if '<' is going to be used to input
> > the less-than operator.  I think more complex syntax-propertization
> > functionality is going to be needed here.  I don't have a tree-sitter
> > build to test, but I'd say that the tree-sitter backend should be asked
> > about what kind of '<' and '>' we're talking about.  AFAICT, just
> > saying that '<' has the delimiter syntax in C++ is wrong. It's not
> > like '(' or '{.'
>
> Yes, you are right.  I think for now it's better to consider them as
> punctuation.
>
> A better idea may be to add a syntax-table text property to "<" and ">"
> when they define a C++ template (or a Java generic).  Tree-sitter can
> match something like a "template_argument_list" node easily, but I
> wonder how to keep this information in sync with the buffer text in the
> most efficient way?

Supposedly this is what I understand tree-sitter to be very very good
at.  My completely naive and absolutely ignorant understanding of the
new tree sitter modes is that once you insert something into the buffer,
tree sitter is immediately notified, recomputes the syntax tree very
efficiently and incrementally, then Emacs can immediately take advantage
of that in the `syntax-propertize-function`, applying the correct syntax
to each separate manifestation of the '<' and '>' characters.  Hopefully
all of this runs in time for post-self-insert-hook to see the correct syntax
class and thus electric-pair-mode, which relies on p-s-i-h can do the
right thing each time.

Again, this is completely my vapourware idea of how all this was
implemented.  I'll also CC: Stefan who is my syntax-propertize
and electric-*-mode sensei.

João
[Message part 2 (text/html, inline)]

This bug report was last modified 2 years and 142 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.