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>
Cc: 59662 <at> debbugs.gnu.org, casouri <at> gmail.com, mardani29 <at> yahoo.es
Subject: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun
Date: Wed, 07 Dec 2022 10:31:13 +0100
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Theodor Thornhill <theo <at> thornhill.no>
>> Cc: "Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife
>>  of text editors" <bug-gnu-emacs <at> gnu.org>, Eli Zaretskii <eliz <at> gnu.org>,
>>  casouri <at> gmail.com, 59662 <at> debbugs.gnu.org
>> Date: Sun, 04 Dec 2022 13:33:35 +0100
>> 
>> Theodor Thornhill <theo <at> thornhill.no> writes:
>> 
>> > On 2 December 2022 22:09:55 CET, "Daniel Martín" <mardani29 <at> yahoo.es> wrote:
>> >>Theodor Thornhill <theo <at> thornhill.no> writes:
>> >>
>> >>> Right - thanks.  However, this makes me wonder - should we really be
>> >>> setting mark here? I see that c-indent-defun does not, and it feels
>> >>> weird that indenting adds to the mark ring.  What do you think?  My
>> >>> first patch used
>> >>>
>> >>> (indent-region
>> >>>   (treesit-node-start node)
>> >>>   (treesit-node-end node))
>> >>>
>> >>> Which behaves similarly to c-indent-defun.
>> >>>
>> >>> See attached patch.
>> >>
>> >>I don't have a strong opinion, but if we can indent without setting the
>> >>mark, I think it'd be a cleaner command.  Specially if c-indent-defun
>> >>doesn't set the mark either.
>> >
>> > Yeah, we don't need to set the mark. Thanks for the feedback :)
>> > Theo
>> 
>> Eli, do you have any opinion on this matter? Should we implement this
>> function without using marks?  That will make the function a smidge
>> bigger, but would not mess up the mark-ring.  I think that's desirable,
>> at least.
>
> IMO, it is better not to set the mark, indeed.

Agreed, see attached patch.  What do you think, Yuan and Eli?

Should we expose the internal helper I used, or maybe this function
could just as well live in treesit.c?

Theo

[0001-Add-c-ts-mode-indent-defun.patch (text/x-diff, attachment)]

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.