Subject: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun

From: Theodor Thornhill <[email-masked]>
Date: Thu, 01 Dec 2022 07:10:14 +0100

Yuan Fu <[email-masked]> writes:

> Theodor Thornhill <[email-masked]> writes:
>
>> Eli Zaretskii <[email-masked]> writes:
>>
>>>> Cc: [email-masked], [email-masked]
>>>> From: Theodor Thornhill <[email-masked]>
>>>> Date: Mon, 28 Nov 2022 20:32:01 +0100

[...]

>>
>>>> An alternative could be to add a 'treesit-mode-map' where we can
>>>> auto-enable such constructs.
>>>
>>> I think this is less desirable.
>>>
>>> Yuan, WDYT?
>>>
> I see, so you want to implement C-c C-q in c-mode. But why don’t we
> make treesit--indent-defun a command and bind it in C-c C-q in major modes? 
> Filling is not indent IMO. If you fill a list in elisp code it wraps long lines 
> instead of indent (IIRC).
>
> Also, this is really not tree-sitter specific, it doesn’t require any
> tree-sitter feature to accomplish: indent-defun only needs mark-defun
> and indent-region, both are supported by practically any major mode.
>
> Normally this kind of thing goes into lisp.el, alongside commands like
> fill-paragraph, indent-region, beginning-of-defun, etc, and claim a
> global keybinding. But maybe we only want it to live under C-c prefix,
> in that case I guess we can bind it in prog-mode-map, under C-c C-q?
>

Yeah, that's smart - thanks for the tip!  Perhaps adding it to prog-mode
is a bit premature, but maybe Eli has an opinion here?

My guess is that a change in lisp.el is a little too big for the release
branch?  So we could let this live in treesit.el if it's too big a
change?

Theo