emacs-devel
[Top][All Lists]
Advanced

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

Re: Allow indentation styles by use of function in tree-sitter


From: Yuan Fu
Subject: Re: Allow indentation styles by use of function in tree-sitter
Date: Mon, 7 Nov 2022 01:13:28 -0800


> On Nov 7, 2022, at 12:00 AM, Theodor Thornhill <theo@thornhill.no> wrote:
> 
> Yuan Fu <casouri@gmail.com> writes:
> 
>>> On Nov 6, 2022, at 4:52 AM, Theodor Thornhill <theo@thornhill.no> wrote:
>>> 
>>> 
>>> Hi Yuan!
>>> 
>>> I was thinking that a quick way to enable indentation styles and
>>> customizable indentation styles is to also accept a function in
>>> tree-sitter-simple-indent.
>>> 
>>> What do you think of the suggested patch?
>>> 
>>> That would allow a defcustom such as
>>> ```
>>> (defcustom c-ts-mode-indent-rule-function #'c-ts-mode--some-specific-style
>>> "Indentation style of choice"
>>> :group 'c)
>>> ```
>>> 
>>> and in the major-mode init:
>>> ```
>>>   (setq-local treesit-simple-indent-rules c-ts-mode-indent-rule-function)
>>> ```
>> 
>> Hmmm, does assigning treesit-indent-function fit the bill?
>> 
> 
> I might be misunderstanding what you mean, but I don't want to change
> the architecture, I just want the user to set their own as a
> customization option in a major mode. The function will just return the
> same stuff as it does now, but with a function as an available option
> that will be a little more flexible.  See [0] for an example.  The user
> can just set [1] to change the indent style.  A quick workaround could
> be that each major mode just does this:
> ```
> (setq-local treesit-simple-indent-rules
>            (funcall c-ts-mode-indent-rule-function))
> ```
> But that is a little less nice :-)

Ah, I see what you mean. I think funcall is perfectly fine. I also think you 
can just define those styles as variables and use symbol-value.

Yuan


reply via email to

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