From unknown Fri Jun 20 07:17:27 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#78003 <78003@debbugs.gnu.org> To: bug#78003 <78003@debbugs.gnu.org> Subject: Status: 31.0.50; comment-indent misbehaves in multiline comments Reply-To: bug#78003 <78003@debbugs.gnu.org> Date: Fri, 20 Jun 2025 14:17:27 +0000 retitle 78003 31.0.50; comment-indent misbehaves in multiline comments reassign 78003 emacs submitter 78003 Sean Whitton severity 78003 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 22 23:18:21 2025 Received: (at submit) by debbugs.gnu.org; 23 Apr 2025 03:18:22 +0000 Received: from localhost ([127.0.0.1]:51347 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u7Qcv-0006rO-6y for submit@debbugs.gnu.org; Tue, 22 Apr 2025 23:18:21 -0400 Received: from lists.gnu.org ([2001:470:142::17]:45022) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u7Qcq-0006qz-6q for submit@debbugs.gnu.org; Tue, 22 Apr 2025 23:18:17 -0400 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 1u7Qci-0005Uw-2t for bug-gnu-emacs@gnu.org; Tue, 22 Apr 2025 23:18:08 -0400 Received: from sendmail.purelymail.com ([34.202.193.197]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u7Qcf-0005xG-6M for bug-gnu-emacs@gnu.org; Tue, 22 Apr 2025 23:18:07 -0400 DKIM-Signature: a=rsa-sha256; b=MTOeGgLYq3ePtgRUkRJhYBdMTljrmBBmOorAD6amWWOFPMlhN76OUbl6GOBAVJWl/peOjLmUFI2XIYLKAnfXJ2Kh+IIFgCNOR2ergkSb3xlmTxJiX7SqoZWDxAw5mTzpgDYAWLKxj6yEuF5urq9y99en5Ir6DT415r/KE7UA/mlcy7VEi+YAEGIL9OKrkENr8H3G+ZQ2UwgrbMjstHyD4EeVRw2xTyJqj2NsbNNtgmiL/TJmyUTMLWbLwewQaW1wGodSoN/C5J9kEQNNYJfCqLeLguICD2iPiFZS1U+YvEmZVvRE7lvgxXOQCXyCRHmaVqWwDmwvImw7IGU1c9L9Bw==; s=purelymail1; d=spwhitton.name; v=1; bh=ldeazfM1PudRURs1aVXWCe9/5tpC9H+bYOeQM77HKoI=; h=Received:Received:From:To:Subject:Date; DKIM-Signature: a=rsa-sha256; b=dLlLJGj9Y1zqj4McFTLWU55rNKzOYJbu7AXCBqWEB2ZxA3dQrHsVfcTJxbHpi1ntnDriSZvGb32cHkhXhTOz/r6+NFORlmKJZ+BgVUkI6aTv8AUuQNnGqt+KREVheETl5kHWqunA1UjDimmFVi7LBaANc94YB/QHICWvEVcZtqR3FYYCIfaeCvgRZQYiF9LafziObY8g7NkpzgVbCjLb99b56Sk1ldR6Hita5w+qff4Dto5FRZQPeHYWAPZtytHZW+/phOM5dveXHGu0TW7N/W6e9iOdjtk5yZHuYZcYPhecjyzh2At9csgFTnyv6UXRxgr2Rl3/NXneF6QDOvOk8Q==; s=purelymail1; d=purelymail.com; v=1; bh=ldeazfM1PudRURs1aVXWCe9/5tpC9H+bYOeQM77HKoI=; h=Feedback-ID:Received:Received:From:To:Subject:Date; Feedback-ID: 20115:3760:null:purelymail X-Pm-Original-To: bug-gnu-emacs@gnu.org Received: by smtp.purelymail.com (Purelymail SMTP) with ESMTPSA id -320497887 for (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Wed, 23 Apr 2025 03:18:03 +0000 (UTC) Received: by melete.silentflame.com (Postfix, from userid 1000) id 7B5007F2EE9; Wed, 23 Apr 2025 11:17:59 +0800 (CST) From: Sean Whitton To: bug-gnu-emacs@gnu.org Subject: 31.0.50; comment-indent misbehaves in multiline comments Date: Wed, 23 Apr 2025 11:17:59 +0800 Message-ID: <87tt6fefbs.fsf@melete.silentflame.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=34.202.193.197; envelope-from=spwhitton@spwhitton.name; helo=sendmail.purelymail.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, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) X-debbugs-cc: monnier@iro.umontreal.ca 1. emacs -q 2. C-x b foo RET 3. M-x lisp-mode RET 4. Enter this content: --8<---------------cut here---------------start------------->8--- #| foo #| --8<---------------cut here---------------end--------------->8--- 5. Put point after "foo". 6. M-; The result is an insertion of trailing single-semicolon comment. As we are already within a comment, this makes no sense. M-; should either do nothing, or possibly perform some form of indentation. We could fix this within comment-dwim. However, I propose instead to change comment-indent (or possibly comment-search-forward). This is because I first encountered this problem not via comment-dwim, but via how indent-sexp calls comment-indent. The above recipe with M-; is just the simplest reproducer I found. Making comment-indent behave better within multiline comments would make it a more useful function in general and also fix these various misbehaviours at once. Other background: - Possibly indent-sexp needs some adjustment too, but any change to comment-indent should come first. - A similar problem shows up with syntax-propertize-function values which set comment-fence syntax-table text properties, which are another kind of multiline comment. (Came up for me in consfigurator.el's syntax-propertize-function.) - A similar problem shows up with the literate-scratch library Stefan M. and I were discussing over the past few days, where the problem is that the library adds a whitespace syntax-table property to some trailing newlines such that it is only the second of the two newlines following a paragraph which ends the comment. With point between the two newlines, we're still in a comment, but comment-indent doesn't think so. -- Sean Whitton From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 24 03:40:16 2025 Received: (at 78003) by debbugs.gnu.org; 24 Apr 2025 07:40:16 +0000 Received: from localhost ([127.0.0.1]:35025 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u7rBv-00087z-JI for submit@debbugs.gnu.org; Thu, 24 Apr 2025 03:40:16 -0400 Received: from sendmail.purelymail.com ([34.202.193.197]:48076) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u7rBr-00084b-Ek for 78003@debbugs.gnu.org; Thu, 24 Apr 2025 03:40:13 -0400 DKIM-Signature: a=rsa-sha256; b=EVd61ROGDoyWm4Vs3IRTAM52+utZvAwd6k6+/V2XH/xNeLNVV10ybTYWND0tg9Dkdh4xjnAPdzDIn8NssoUjZR8niv65slOdqD+uLIyPhowNv1wFyaYa+eX/IsknsAFX0ozpGNdjwh4ELeS52irm0AAmHWOBqq1vb7Z76L+/1jUTDpDnz4CUhLEPQICZgjm9YnyFFXfEBs8e/tP4VvAN7nEg7sQK9pwhJyj+AhYUf+Zi0cw9/tEYrQt230PZmmLqnBKyYsovaA+nUb6K5RwfXcXc3fR4XSljlyzdPsCdXKykI9jt6DuRajUDhe80mJ4oAec+AQH0IF2HLV2x5UidXg==; s=purelymail1; d=spwhitton.name; v=1; bh=Mp/lJOHznOyppN4H9d229PWkNwkHH/vnP7qLwPN2530=; h=Received:Received:From:To:Subject:Date; DKIM-Signature: a=rsa-sha256; b=AbcZYvhsNB3/yhrOu18KGrSEpJZQGsX7QrJFaE6/+xO008VxPzdufGD12aTA9i70aCA8GUThxQv9WrhJZ5sYI3oRR255JmMAz3+Q15pgaV9Gac3EyD2n1joecIo0ejav1x8tLmq0mI1raW+JZblQBVYtcedctMpiA/ZGSaug7tnk5I8umQ3M/eFF9OLc9sbwJFdWKCJ/crzBuWebrgUJMyZMLI0n7xv9ELHrPVEu99ip1KbQpfI30BFQo/fLKWbIbIbJ5vdh7Bn5O5vH/Cqxz5ZsfZaEvNeWU8S2nI4R5qNhhjjgTnRWdgeK5E4P48s9t1uuYkVnYDuEuU+pIzucoA==; s=purelymail1; d=purelymail.com; v=1; bh=Mp/lJOHznOyppN4H9d229PWkNwkHH/vnP7qLwPN2530=; h=Feedback-ID:Received:Received:From:To:Subject:Date; Feedback-ID: 20115:3760:null:purelymail X-Pm-Original-To: 78003@debbugs.gnu.org Received: by smtp.purelymail.com (Purelymail SMTP) with ESMTPSA id -346899087; (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Thu, 24 Apr 2025 07:40:03 +0000 (UTC) Received: by melete.silentflame.com (Postfix, from userid 1000) id CA9357F32B3; Thu, 24 Apr 2025 15:40:00 +0800 (CST) From: Sean Whitton To: 78003@debbugs.gnu.org, Stefan Monnier Subject: Re: bug#78003: Acknowledgement (31.0.50; comment-indent misbehaves in multiline comments) In-Reply-To: References: <87tt6fefbs.fsf@melete.silentflame.com> Date: Thu, 24 Apr 2025 15:40:00 +0800 Message-ID: <87h62em2i7.fsf@melete.silentflame.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78003 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Hello, Proposed fix for the comment-indent part of this attached. -- Sean Whitton --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-comment-indent-Handle-BOL-already-within-a-multiline.patch >From 7b4eec6dfe757260a6976a59a2728ba26a46d551 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Thu, 24 Apr 2025 15:38:34 +0800 Subject: [PATCH] comment-indent: Handle BOL already within a multiline comment * lisp/newcomment.el (comment-indent): Newly handle the case that BOL is already within a multiline comment (bug#78003). --- lisp/newcomment.el | 51 ++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/lisp/newcomment.el b/lisp/newcomment.el index 23fcbc05372..fd498fe934c 100644 --- a/lisp/newcomment.el +++ b/lisp/newcomment.el @@ -719,8 +719,17 @@ comment-indent comment-end))) (unless starter (error "No comment syntax defined")) (beginning-of-line) - (let* ((eolpos (line-end-position)) - (begpos (comment-search-forward eolpos t)) + (let* ((startpos (comment-search-forward (line-end-position) t)) + (begpos (or startpos + ;; If we couldn't find a comment *starting* on + ;; this line, see if we are already within a + ;; multiline comment at BOL (bug#78003). + (and (not continue) + comment-use-syntax comment-use-global-state + (let ((st (syntax-ppss (line-beginning-position)))) + (and (nth 4 st) (< (nth 8 st) (point)) + (point)))))) + (multilinep (and (not startpos) begpos)) cpos indent) (if (and comment-insert-comment-function (not begpos)) ;; If no comment and c-i-c-f is set, let it do everything. @@ -750,22 +759,28 @@ comment-indent (setq cpos (point-marker)) (insert ender))) (goto-char begpos) - ;; Compute desired indent. - (setq indent (save-excursion (funcall comment-indent-function))) - ;; If `indent' is nil and there's code before the comment, we can't - ;; use `indent-according-to-mode', so we default to comment-column. - (unless (or indent (save-excursion (skip-chars-backward " \t") (bolp))) - (setq indent comment-column)) - (if (not indent) - ;; comment-indent-function refuses: delegate to line-indent. - (indent-according-to-mode) - ;; If the comment is at the right of code, adjust the indentation. - (unless (save-excursion (skip-chars-backward " \t") (bolp)) - (setq indent (comment-choose-indent indent))) - ;; If that's different from comment's current position, change it. - (unless (= (current-column) indent) - (delete-region (point) (progn (skip-chars-backward " \t") (point))) - (indent-to indent))) + ;; Compute desired indent. + (if multilinep + ;; We don't know anything about the nature of the multiline + ;; construct, so immediately delegate to the mode. + (indent-according-to-mode) + (setq indent (save-excursion (funcall comment-indent-function))) + ;; If `indent' is nil and there's code before the comment, we can't + ;; use `indent-according-to-mode', so we default to comment-column. + (unless (or indent + (save-excursion (skip-chars-backward " \t") (bolp))) + (setq indent comment-column)) + (if (not indent) + ;; comment-indent-function refuses: delegate to line-indent. + (indent-according-to-mode) + ;; If the comment is at the right of code, adjust the indentation. + (unless (save-excursion (skip-chars-backward " \t") (bolp)) + (setq indent (comment-choose-indent indent))) + ;; If that's different from comment's current position, change it. + (unless (= (current-column) indent) + (delete-region (point) + (progn (skip-chars-backward " \t") (point))) + (indent-to indent)))) (goto-char cpos) (set-marker cpos nil))))) -- 2.49.0 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 24 14:58:29 2025 Received: (at 78003) by debbugs.gnu.org; 24 Apr 2025 18:58:29 +0000 Received: from localhost ([127.0.0.1]:41233 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u81mG-0001WB-SH for submit@debbugs.gnu.org; Thu, 24 Apr 2025 14:58:29 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:54424) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u81mB-0001Vc-93 for 78003@debbugs.gnu.org; Thu, 24 Apr 2025 14:58:25 -0400 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 8B1BB1000BC; Thu, 24 Apr 2025 14:58:16 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1745521095; bh=SSPoRw0wVOAA/cfuFLK+W1v9HjlZfq8wPcGl+3ozD9A=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=pQ974usQPjIc9T7qH9hm9WYeaLWbd3WIhwtWAzgsWfLWSOZEhv6Q2rLHt5m1VBbAS lthNkYRGf1j1nvSczO9hJnc05oVyRANuHLGsLt8LRZBDPaTRXkPLpSvdApMeETn38N n8rePVQMaJ8nIc7AA9e+ae7hP/0nfQXyTkJHaNBgkk5OyGTYMhr0FlSdkVhirJ5pap Y92VN9y3zIMcs6B94x1txfhRX5OIJzvPN9oANk5EFlkeQsQnfbaBHx2CksrSIAW0gP 3T6Fr25rPASqjLGYl5la69+pyGwJ5Ya8SZdFCAuYXQBDJyhQMSI4qgFlzg6r8oVWPI O5K3ogKY1bMhA== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id BC13E10002E; Thu, 24 Apr 2025 14:58:15 -0400 (EDT) Received: from alfajor (unknown [23.233.149.155]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 9FE7F1205F4; Thu, 24 Apr 2025 14:58:15 -0400 (EDT) From: Stefan Monnier To: Sean Whitton Subject: Re: bug#78003: Acknowledgement (31.0.50; comment-indent misbehaves in multiline comments) In-Reply-To: <87h62em2i7.fsf@melete.silentflame.com> Message-ID: References: <87tt6fefbs.fsf@melete.silentflame.com> <87h62em2i7.fsf@melete.silentflame.com> Date: Thu, 24 Apr 2025 14:58:14 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.208 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 78003 Cc: 78003@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) --=-=-= Content-Type: text/plain > We could fix this within comment-dwim. I don't think we could because `comment-indent` is also a command. Maybe we could make `comment-dwim` do something more useful than calling `comment-indent` in that case, but that's "another problem". > However, I propose instead to change comment-indent (or possibly > comment-search-forward). +1 > - (let* ((eolpos (line-end-position)) > - (begpos (comment-search-forward eolpos t)) > + (let* ((startpos (comment-search-forward (line-end-position) t)) > + (begpos (or startpos > + ;; If we couldn't find a comment *starting* on > + ;; this line, see if we are already within a > + ;; multiline comment at BOL (bug#78003). > + (and (not continue) > + comment-use-syntax comment-use-global-state > + (let ((st (syntax-ppss (line-beginning-position)))) > + (and (nth 4 st) (< (nth 8 st) (point)) > + (point)))))) > + (multilinep (and (not startpos) begpos)) AFAICT we don't need to check (< (nth 8 st) (point)). Am I missing something? Also, I think the bug will still bite when `comment-insert-comment-function` is set. BTW, the patch looks simple in terms of the diff, but it makes the control flow (which is already not great) even more complicated. How 'bout the one below? Stefan --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=comment-indent.patch diff --git a/lisp/newcomment.el b/lisp/newcomment.el index 23fcbc05372..d04090c0a75 100644 --- a/lisp/newcomment.el +++ b/lisp/newcomment.el @@ -713,18 +713,28 @@ If CONTINUE is non-nil, use the `comment-continue' markers if any." (interactive "*") (comment-normalize-vars) - (let ((starter (or (and continue comment-continue) - comment-start)) - (ender (or (and continue comment-continue "") - comment-end))) - (unless starter (error "No comment syntax defined")) (beginning-of-line) - (let* ((eolpos (line-end-position)) + (let* ((starter (or (and continue comment-continue) + comment-start + (error "No comment syntax defined"))) + (ender (or (and continue comment-continue "") + comment-end)) + (eolpos (line-end-position)) (begpos (comment-search-forward eolpos t)) cpos indent) - (if (and comment-insert-comment-function (not begpos)) + (cond + ;; If we couldn't find a comment *starting* on this line, see + ;; if we are already within a multiline comment at BOL (bug#78003). + ((and (not begpos) (not continue) + comment-use-syntax comment-use-global-state + (nth 4 (syntax-ppss (line-beginning-position)))) + ;; We don't know anything about the nature of the multiline + ;; construct, so immediately delegate to the mode. + (indent-according-to-mode)) + ((and comment-insert-comment-function (not begpos)) ;; If no comment and c-i-c-f is set, let it do everything. - (funcall comment-insert-comment-function) + (funcall comment-insert-comment-function)) + (t ;; An existing comment? (if begpos (progn --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 24 21:15:35 2025 Received: (at 78003-done) by debbugs.gnu.org; 25 Apr 2025 01:15:35 +0000 Received: from localhost ([127.0.0.1]:43279 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u87fD-0001Nv-A8 for submit@debbugs.gnu.org; Thu, 24 Apr 2025 21:15:35 -0400 Received: from sendmail.purelymail.com ([34.202.193.197]:49930) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u87fA-0001Ng-HA for 78003-done@debbugs.gnu.org; Thu, 24 Apr 2025 21:15:33 -0400 DKIM-Signature: a=rsa-sha256; b=fsbY0L+dyaYDGpTRVTO1RaN8z3Z/M+r+5hNC9q5iNyCYgda9a21TrRS+IKKuU8tcP3nEgi2DGeMgI/xtp65frTQpXQ9PIIiM2Ts1Rl7ysQKj1xludDc11ij0SUu5t5b90jXlreifv73czeDfS0PqGOT8UJCD/1qa/p6XECGX30HpYJdkeL/OC6rkMyMQtaqCi44W2a6MaH5x866hPBCJOy+xiDGhB9gevbVaQj+XW2KcfKQJSz3RWKPVIfbx0G1UhTxsUBjjBAJ9E6akQsByV1KgOZ6HmoacAtPBv5BwnIL+H4TNVs3zk6t+4wCQyi9lx1jnFx7Fp4QAWB6/rIFiWA==; s=purelymail1; d=spwhitton.name; v=1; bh=05oFVVyIRUwvA330QLhyqAVHCL3WZ3wVCmvKbYWy6fA=; h=Received:Received:From:To:Subject:Date; DKIM-Signature: a=rsa-sha256; b=jD4UbKuOsAWcRPvHam5OtAbGfI4ttAmxm7nD2wUU2Ii0PmG8kKwoce/CTPIV+sv91WuvydFZhqNKYnz/hd0yPKLtgOujl2xrMFjx6oWodjuNhl5ekOAhUl2xIqy3R4jJucrQ36I/z4oCE0J+Spg+juZoImV8yJIbN/Vqar4HqsYKiYobSkUSemQ0JqpjXYGCdmw7O23h1+FTEA41ler7ic/CS0EQCVngpdkeqoPIrAExsTjMxd16uQ4YPGjzI4JKAl6QqLRC07YmGQB8R/8DrZi28KUPy9IU0RVO5zDpzIo6QPCeYCKrXO3QnoTR9r6Um2KDn78+GgiDK9oLoC75Dg==; s=purelymail1; d=purelymail.com; v=1; bh=05oFVVyIRUwvA330QLhyqAVHCL3WZ3wVCmvKbYWy6fA=; h=Feedback-ID:Received:Received:From:To:Subject:Date; Feedback-ID: 20115:3760:null:purelymail X-Pm-Original-To: 78003-done@debbugs.gnu.org Received: by smtp.purelymail.com (Purelymail SMTP) with ESMTPSA id 875082336; (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Fri, 25 Apr 2025 01:15:26 +0000 (UTC) Received: by melete.silentflame.com (Postfix, from userid 1000) id B06147F34A6; Fri, 25 Apr 2025 09:15:23 +0800 (CST) From: Sean Whitton To: Stefan Monnier Subject: Re: bug#78003: 31.0.50; comment-indent misbehaves in multiline comments In-Reply-To: References: <87tt6fefbs.fsf@melete.silentflame.com> <87h62em2i7.fsf@melete.silentflame.com> Date: Fri, 25 Apr 2025 09:15:23 +0800 Message-ID: <87v7qtkpn8.fsf_-_@melete.silentflame.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78003-done Cc: 78003-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Version: 31.1 Hello, On Thu 24 Apr 2025 at 02:58pm -04, Stefan Monnier wrote: >> We could fix this within comment-dwim. > > I don't think we could because `comment-indent` is also a command. > Maybe we could make `comment-dwim` do something more useful than calling > `comment-indent` in that case, but that's "another problem". Right. > AFAICT we don't need to check (< (nth 8 st) (point)). > Am I missing something? I think you are correct that it does not need to be checked because this call to `<' could only return nil in the case that comment-search-forward returned non-nil, in which case we would not be calling syntax-ppss at all. > Also, I think the bug will still bite when > `comment-insert-comment-function` is set. Yes, I was thinking that handling it in that case is going to have to be the responsibility of whatever function is set. But it ought to know what's going on better than comment-indent does. > BTW, the patch looks simple in terms of the diff, but it makes the > control flow (which is already not great) even more complicated. > > How 'bout the one below? Thanks for reviewing, and for reworking it. Installed the change. There are other bugs nearby that I hope to fix soon but nothing actionable remaining here, so closing the bug. -- Sean Whitton From unknown Fri Jun 20 07:17:27 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 23 May 2025 11:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator