emacs-devel
[Top][All Lists]
Advanced

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

Re: c-ts-mode


From: Yuan Fu
Subject: Re: c-ts-mode
Date: Mon, 11 Sep 2023 17:34:12 -0700


> On Sep 8, 2023, at 4:25 AM, Eli Zaretskii <eliz@gnu.org> wrote:
> 
>> From: João Távora <joaotavora@gmail.com>
>> Cc: Theodor Thornhill <theo@thornhill.no>,  casouri@gmail.com,
>>  spacibba@aol.com,  emacs-devel@gnu.org
>> Date: Fri, 08 Sep 2023 08:25:50 +0100
>> 
>>> What I had in mind was a simple alist, like CC Mode uses, with an
>>> infrastructure function to install it.  Patches are welcome.
>> 
>> It would certainly work for me, at least for my very simple case, and I
>> would be happy for this.  Not sure it is half as powerful, for example
>> how would you make that simple alist express cases where you want to add
>> the rules _after_ the base set?
> 
> How does CC Mode support this (if it does)?  I think we should allow
> users of CC Mode easy migration to c-ts-mode.  Anything beyond that
> is, of course, welcome, but it is less important from my POV.
> 
> I'll let Theo and Yuan chime in on the other points you make.

I don’t think users would be happy if they need to know CLOS to customize 
indentation rules. IMO users would be better off modifying 
treesit-simple-indent-rules in the major mode hook. It’s an alist of (LANGUAGE 
. RULES). 

So something like

(setf (alist-get 'lang treesit-simple-indent-rules)
      (append '(custom-rules...)
              (alist-get 'lang treesit-simple-indent-rules)))

Would do the trick.

Admittedly that’s a tiny bit clunky, we can add a helper function like 
(treesit-simple-indent-add-rules RULES &optional LANG).

Yuan


reply via email to

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