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: larsi <at> gnus.org, 59662 <at> debbugs.gnu.org, casouri <at> gmail.com, monnier <at> iro.umontreal.ca, dgutov <at> yandex.ru
Subject: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun
Date: Sat, 10 Dec 2022 21:21:53 +0100
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Theodor Thornhill <theo <at> thornhill.no>
>> Cc: dgutov <at> yandex.ru, larsi <at> gnus.org, 59662 <at> debbugs.gnu.org,
>>  casouri <at> gmail.com, monnier <at> iro.umontreal.ca
>> Date: Fri, 09 Dec 2022 22:09:10 +0100
>> 
>> Something like the patch below?  Forgive me, but my texinfo-fu is
>> limited.
>
> You have nothing to worry in that department.
>
>> I'm a little unsure if I xrefed to the correct nodes.  Maybe
>> it is better to just mention 'beginning-of-defun' rather than the
>> variable 'beginning-of-defun-function'?
>
> I meant a reference to where beginning-of-defun-function is mentioned,
> and that is in the ELisp manual.  You can see examples of how to
> reference another manual in many places in doc/emacs/*.texi; seartch
> for "elisp".
>

Ok, thanks!

>> >> +(defun prog-fill-reindent-defun (&optional argument)
>> >> +  "Refill paragraph or reindent the definition that the point is on.
>> >> +
>> >> +If the point is in a string, or in a comment, or there is a
>> >> +comment on the current line, fill the paragraph that the point is
>> >> +in or is on the same line.
>> >
>> > I don't understand the difference between "point is in a string, or in
>> > a comment" and "there is a comment on the current line".  
>> >
>> >> +Otherwise, reindent the definition around or below point."
>> >
>> > Likewise this one is confusing.
>> 
>> I'm not sure how to word this differently, but I agree it's a mouthful.
>
> If you explain to me in plain English what you meant, I can suggest a
> better wording.
>

I made another attempt - I think it's a little clearer.  What I want to
say is something like this (| denotes point):

1. If point is inside a comment, refill the paragraph:
  // foo bar | baz

2. If point is before a comment, refill the paragraph:
 |  // foo bar baz

3. If point is inside code, reindent the defun:
int
main(void)
{
             int i;          // <-- This will be reindented
  /* Some very long comment that will _not_ be refilled in this case.  */
  for(;;)
    {
  |   int x;
    }
}

Anyway, see attached patch:

Theo

[0001-Add-prog-fill-reindent-defun-bug-59664.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.