[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun
From: |
Theodor Thornhill |
Subject: |
bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun |
Date: |
Thu, 01 Dec 2022 08:22:45 +0100 |
On 1 December 2022 08:13:22 CET, Eli Zaretskii <eliz@gnu.org> wrote:
>> 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.)
So you'd like the change in lisp.el, but bound only in the modes you mention,
or have something similar to the original patch in treesit, but still bound
only to the same modes?
Theo
- bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun, Theodor Thornhill, 2022/12/01
- bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun, Eli Zaretskii, 2022/12/01
- bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun,
Theodor Thornhill <=
- bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun, Eli Zaretskii, 2022/12/01
- bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun, Theodor Thornhill, 2022/12/01
- bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun, Theodor Thornhill, 2022/12/02
- bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun, Eli Zaretskii, 2022/12/02
- bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun, Theodor Thornhill, 2022/12/02
- bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun, Eli Zaretskii, 2022/12/02
- bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun, Daniel Martín, 2022/12/02
- bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun, Theodor Thornhill, 2022/12/02
- bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun, Daniel Martín, 2022/12/02
- bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun, Theodor Thornhill, 2022/12/02