From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs 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 Message-ID: <87r0wn87yz.fsf@thornhill.no> Reply-To: Theodor Thornhill Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5403"; mail-complaints-to="usenet@ciao.gmane.io" To: 60322@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Dec 25 22:55:16 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p9Yxf-0001DG-V9 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 25 Dec 2022 22:55:16 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p9YxV-0000pU-3d; Sun, 25 Dec 2022 16:55:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p9YxT-0000p6-6P for bug-gnu-emacs@gnu.org; Sun, 25 Dec 2022 16:55:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p9YxS-0008ET-PA for bug-gnu-emacs@gnu.org; Sun, 25 Dec 2022 16:55:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p9YxS-0003Sr-Iz for bug-gnu-emacs@gnu.org; Sun, 25 Dec 2022 16:55:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Theodor Thornhill Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 25 Dec 2022 21:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 60322 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.167200529513293 (code B ref -1); Sun, 25 Dec 2022 21:55:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 25 Dec 2022 21:54:55 +0000 Original-Received: from localhost ([127.0.0.1]:50215 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p9YxL-0003SK-GG for submit@debbugs.gnu.org; Sun, 25 Dec 2022 16:54:55 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:50058) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p9YxJ-0003SB-JP for submit@debbugs.gnu.org; Sun, 25 Dec 2022 16:54:54 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p9YxJ-0000mu-E2 for bug-gnu-emacs@gnu.org; Sun, 25 Dec 2022 16:54:53 -0500 Original-Received: from out2.migadu.com ([188.165.223.204]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p9YxH-00088O-Af for bug-gnu-emacs@gnu.org; Sun, 25 Dec 2022 16:54:53 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1672005287; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=i7BRjIZQ+f0Rg9GYG50wzYAJS3N+LAYxg/KdsGa+zew=; b=MvH8XjsWKDCVIQuHRz2vaFjsW+LN7kVBfRZS1tju5XfHGKG8vT9rc67ClUWildAEqGvYiX TGFh79tOA8sxUraoHSIS0ajCLKM9NTlflKcFrGJEiiGG9s5TExOEtjkjqRp66raSvsb/+h c1PX0Y1I2txfZcqzmV9LB0BV77wNC5ozS4q8Xczc+LWobW4M5BAtUfPUkeAAgX9iGRD/+o BSqPeQjtTZHnTjytkn3czv2FU/3+l3AozXphwygKzN3myu1lDN/aSKoFXM9CCTA7283CNv nKQ+RK2Bhj81h55t9Qb+5U07yVDzCJVYLirdTktAWC6qdujWGeZDInZ27iqwtg== X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=188.165.223.204; envelope-from=theo@thornhill.no; helo=out2.migadu.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:251874 Archived-At: --=-=-= Content-Type: text/plain 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 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Search-for-comment-at-bol-in-prog-fill-reindent-defu.patch >From 8cbd514496d45e3b22523c5dc303abf97b3761f7 Mon Sep 17 00:00:00 2001 From: Theodor Thornhill 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 --=-=-=--