On Thu, Dec 15, 2022 at 9:34 PM Daniel Martín wrote: > > João Távora 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