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

From: Eli Zaretskii <[email-masked]>
Date: Thu, 01 Dec 2022 09:13:22 +0200

> From: Yuan Fu <[email-masked]>
> Date: Wed, 30 Nov 2022 15:23:17 -0800
> Cc: Eli Zaretskii <[email-masked]>,
>  [email-masked],
>  [email-masked]
> 
> 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?
> 
> I’m thinking something like
> 
> (defun prog-mode-indent-defun ()
>   (interactive)
>   (mark-defun)
>   (indent-region (region-beginning) (region-end)))
> 
> (defvar prog-mode-map
>   (...
>    (define-key map (kbd "C-c C-q") #'prog-mode-indent-defun)))

SGTM, but I'd begin by doing this only in c-ts-mode.el (and maybe also in
csharp-ts-mode).  After all, until now this functionality and the "C-c C-q"
binding was only in CC Mode.  (My original question about this was due to
lack of enthusiasm to add the "C Indent" node of the Emacs manual text that
explains this feature is only available in CC Mode, not in the tree-sitter
based C/C++ modes.)