GNU bug report logs - #59662
29.0.50; [PATCH] Add treesit--indent-defun

Previous Next

Package: emacs;

Reported by: Theodor Thornhill <theo <at> thornhill.no>

Date: Mon, 28 Nov 2022 19:33:01 UTC

Severity: wishlist

Tags: patch

Found in version 29.0.50

Done: Yuan Fu <casouri <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Theodor Thornhill <theo <at> thornhill.no>
To: Eli Zaretskii <eliz <at> gnu.org>, Yuan Fu <casouri <at> gmail.com>
Cc: 59662 <at> debbugs.gnu.org, casouri <at> gmail.org
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 <at> gnu.org> wrote:
>> From: Yuan Fu <casouri <at> gmail.com>
>> Date: Wed, 30 Nov 2022 15:23:17 -0800
>> Cc: Eli Zaretskii <eliz <at> gnu.org>,
>>  59662 <at> debbugs.gnu.org,
>>  casouri <at> 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




This bug report was last modified 2 years and 158 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.