emacs-devel
[Top][All Lists]
Advanced

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

Re: c-ts-mode


From: Eli Zaretskii
Subject: Re: c-ts-mode
Date: Fri, 08 Sep 2023 09:14:39 +0300

> From: João Távora <joaotavora@gmail.com>
> Date: Thu, 7 Sep 2023 23:01:58 +0100
> Cc: casouri@gmail.com, spacibba@aol.com, emacs-devel@gnu.org
> 
> On Thu, Sep 7, 2023 at 7:32 PM Eli Zaretskii <eliz@gnu.org> wrote:
> >
> > > From: João Távora <joaotavora@gmail.com>
> > > Date: Thu, 7 Sep 2023 19:23:33 +0100
> > > Cc: casouri@gmail.com, spacibba@aol.com, emacs-devel@gnu.org
> > >
> > > The real challenge is writing the rules themselves.  I'm missing
> > > a kind of "debug rule" that doesn't do anything but prints out
> > > contextual information from the node, parent-node, grandparents.
> > > I made one but it's not very good.  Is there something like that?
> > > Wouldn't even need to be an indentation rule, more like a "describe
> > > AST at point"...
> >
> > Did you try "M-x treesit-explore-mode RET"?
> 
> That's a great find, and so is M-x treesit-inspect-mode.
> 
> My rules are now done.
> 
> (setq c-ts-mode-indent-style
>       (lambda ()
>         (append '(((n-p-gp nil nil "namespace_definition") grand-parent 0)
>                   ((n-p-gp nil nil "linkage_specification") grand-parent 0))
>                 (alist-get 'gnu (c-ts-mode--indent-styles 'cpp)))))
> 
> The lambda, cl-list*, the alist-get and the '--' are ugly but
> beyond that, it's better than cc-mode's system, to be honest.
> 
> Anyway, to get the ugly out, here's an idea.
> 
> IMHO making c-ts-mode--indent-styles a public CL-style
> generic function would be a good possibility.

Sorry, I don't understand: since we already allow
c-ts-mode-indent-style to be a function, why do we need any other
function-based feature?  If the only reason is that the function form
of c-ts-mode-indent-style looks ugly to you, then I think this is in
the eyes of the beholder; it doesn't look ugly to me, FWIW.

> A defcustom-style thing for customize lovers can also be added,
> later for people that don't like defgeneric.  Seems like a pretty
> large DSL to code up in customize, though.

What I had in mind was a simple alist, like CC Mode uses, with an
infrastructure function to install it.  Patches are welcome.

Yuan and Theo, would you like to work on adding such feature to
c-ts-common?



reply via email to

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