unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Dmitry Gutov <dgutov@yandex.ru>, 60322@debbugs.gnu.org
Subject: bug#60322: 30.0.50; [PATCH]: Search for comment at bol in prog-fill-reindent-defun
Date: Thu, 29 Dec 2022 20:23:08 +0100	[thread overview]
Message-ID: <87tu1eovz7.fsf@thornhill.no> (raw)
In-Reply-To: <1a6503f9-31be-7015-64a4-6776e510a855@yandex.ru>

[-- Attachment #1: Type: text/plain, Size: 535 bytes --]

Dmitry Gutov <dgutov@yandex.ru> writes:

> On 25/12/2022 23:54, Theodor Thornhill via Bug reports for GNU Emacs, 
> the Swiss army knife of text editors wrote:
>> Attached is a small adjustment to the regex used in
>> prog-fill-reindent-defun.  The point is that we shouldn't consider lines
>> where comments come after actual code as inside a comment.
>
> How about we allow indentation?
>
> And allow to be called not from BOL too?
>
> (re-search-forward "\\s-*\\s<" (line-end-position) t)

Sure!

Will you install it for me?

Theo


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Allow-for-indentation-in-prog-fill-reindent-defun.patch --]
[-- Type: text/x-diff, Size: 1018 bytes --]

From b92043c5f1c3f835d19aa9d632920804283eccfd Mon Sep 17 00:00:00 2001
From: Theodor Thornhill <theo@thornhill.no>
Date: Thu, 29 Dec 2022 20:19:46 +0100
Subject: [PATCH] Allow for indentation in prog-fill-reindent-defun

(bug#60322)

* lisp/progmodes/prog-mode.el (prog-fill-reindent-defun): Adjust
regexp.
---
 lisp/progmodes/prog-mode.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el
index 5e692980b2..2e0cb6cd25 100644
--- a/lisp/progmodes/prog-mode.el
+++ b/lisp/progmodes/prog-mode.el
@@ -164,7 +164,7 @@ prog-fill-reindent-defun
                  (treesit-node-type (treesit-node-at (point)))))))
       (if (or treesit-text-node
               (nth 8 (syntax-ppss))
-              (re-search-forward "^\\s<" (line-end-position) t))
+              (re-search-forward "\\s-*\\s<" (line-end-position) t))
           (fill-paragraph argument (region-active-p))
         (beginning-of-defun)
         (let ((start (point)))
-- 
2.34.1


  reply	other threads:[~2022-12-29 19:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-25 21:54 bug#60322: 30.0.50; [PATCH]: Search for comment at bol in prog-fill-reindent-defun Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-29  9:02 ` Eli Zaretskii
2022-12-29 10:48   ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-29 11:12     ` Eli Zaretskii
2022-12-29 16:04 ` Dmitry Gutov
2022-12-29 19:23   ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2022-12-29 19:25     ` Dmitry Gutov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tu1eovz7.fsf@thornhill.no \
    --to=bug-gnu-emacs@gnu.org \
    --cc=60322@debbugs.gnu.org \
    --cc=dgutov@yandex.ru \
    --cc=theo@thornhill.no \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).