all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Yuan Fu <casouri@gmail.com>
To: Theodor Thornhill <theo@thornhill.no>
Cc: emacs-devel@gnu.org
Subject: Re: Allow indentation styles by use of function in tree-sitter
Date: Mon, 7 Nov 2022 01:13:28 -0800	[thread overview]
Message-ID: <E8A12097-C94F-46A7-AC70-FB620921766A@gmail.com> (raw)
In-Reply-To: <87y1sni489.fsf@thornhill.no>



> 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	other threads:[~2022-11-07  9:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-06 12:52 Allow indentation styles by use of function in tree-sitter Theodor Thornhill
2022-11-07  0:06 ` Yuan Fu
2022-11-07  8:00   ` Theodor Thornhill
2022-11-07  9:13     ` Yuan Fu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E8A12097-C94F-46A7-AC70-FB620921766A@gmail.com \
    --to=casouri@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=theo@thornhill.no \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.