From: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 60322@debbugs.gnu.org
Subject: bug#60322: 30.0.50; [PATCH]: Search for comment at bol in prog-fill-reindent-defun
Date: Sun, 25 Dec 2022 22:54:44 +0100 [thread overview]
Message-ID: <87r0wn87yz.fsf@thornhill.no> (raw)
[-- Attachment #1: Type: text/plain, Size: 198 bytes --]
Hi!
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.
Theo
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Search-for-comment-at-bol-in-prog-fill-reindent-defu.patch --]
[-- Type: text/x-diff, Size: 1224 bytes --]
From 8cbd514496d45e3b22523c5dc303abf97b3761f7 Mon Sep 17 00:00:00 2001
From: Theodor Thornhill <theo@thornhill.no>
Date: Sun, 25 Dec 2022 22:47:36 +0100
Subject: [PATCH] Search for comment at bol in prog-fill-reindent-defun
Ensure that we don't consider lines such as
switch (foo) {
case 2: // If point on 'c' in 'case'
return 2;
not to be considered for filling.
* lisp/progmodes/prog-mode.el (prog-fill-reindent-defun): Adjust
regex.
---
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 aa37a4ac86..cebd759a4e 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 comment-start-skip (line-end-position) t))
+ (re-search-forward "^\\s<" (line-end-position) t))
(if (memq fill-paragraph-function '(t nil))
(lisp-fill-paragraph argument)
(funcall fill-paragraph-function argument))
--
2.34.1
next reply other threads:[~2022-12-25 21:54 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-25 21:54 Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2022-12-29 9:02 ` bug#60322: 30.0.50; [PATCH]: Search for comment at bol in prog-fill-reindent-defun 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
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r0wn87yz.fsf@thornhill.no \
--to=bug-gnu-emacs@gnu.org \
--cc=60322@debbugs.gnu.org \
--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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.