bug-gnu-emacs
[Top][All Lists]
Advanced

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

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


From: Eli Zaretskii
Subject: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun
Date: Thu, 01 Dec 2022 09:13:22 +0200

> From: Yuan Fu <casouri@gmail.com>
> Date: Wed, 30 Nov 2022 15:23:17 -0800
> Cc: Eli Zaretskii <eliz@gnu.org>,
>  59662@debbugs.gnu.org,
>  casouri@gmail.org
> 
> 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.)





reply via email to

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