From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh Newsgroups: gmane.emacs.bugs Subject: bug#66670: [PATCH] Use buffer-local comment-continue in comment-indent-new-line Date: Sat, 21 Oct 2023 16:08:42 -0400 Message-ID: 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="7777"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Stefan Monnier To: 66670@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Oct 21 22:09:47 2023 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 1quII7-0001nc-0T for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 21 Oct 2023 22:09:47 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1quIHw-0001H2-8x; Sat, 21 Oct 2023 16:09:36 -0400 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 1quIHv-0001Gq-28 for bug-gnu-emacs@gnu.org; Sat, 21 Oct 2023 16:09:35 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1quIHu-0007bQ-QY for bug-gnu-emacs@gnu.org; Sat, 21 Oct 2023 16:09:34 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1quIIM-0005NX-Af for bug-gnu-emacs@gnu.org; Sat, 21 Oct 2023 16:10:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 21 Oct 2023 20:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 66670 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.169791896920623 (code B ref -1); Sat, 21 Oct 2023 20:10:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 21 Oct 2023 20:09:29 +0000 Original-Received: from localhost ([127.0.0.1]:45132 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1quIHl-0005MW-7u for submit@debbugs.gnu.org; Sat, 21 Oct 2023 16:09:29 -0400 Original-Received: from lists.gnu.org ([2001:470:142::17]:48218) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1quIHf-0005KS-4P for submit@debbugs.gnu.org; Sat, 21 Oct 2023 16:09:23 -0400 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 1quIH7-00019u-KW for bug-gnu-emacs@gnu.org; Sat, 21 Oct 2023 16:08:45 -0400 Original-Received: from mxout5.mail.janestreet.com ([64.215.233.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1quIH5-0007Ts-W4 for bug-gnu-emacs@gnu.org; Sat, 21 Oct 2023 16:08:45 -0400 Received-SPF: pass client-ip=64.215.233.18; envelope-from=sbaugh@janestreet.com; helo=mxout5.mail.janestreet.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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:272937 Archived-At: --=-=-= Content-Type: text/plain Tags: patch This fixes a remaining issue with whitespace values of comment-continue, as described in https://github.com/ocaml/tuareg/issues/216 Namely, the fixes done so far don't cover comment-indent-new-line. In GNU Emacs 29.1.50 (build 12, x86_64-pc-linux-gnu, X toolkit, cairo version 1.15.12, Xaw scroll bars) of 2023-10-19 built on igm-qws-u22796a Repository revision: 9163e634e296435aa7a78bc6b77b4ee90666d2ac Repository branch: emacs-29 Windowing system distributor 'The X.Org Foundation', version 11.0.12011000 System Description: Rocky Linux 8.8 (Green Obsidian) Configured using: 'configure --config-cache --with-x-toolkit=lucid --with-gif=ifavailable' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-Use-buffer-local-comment-continue-in-comment-indent-.patch >From 9fab95f193eb7da9e6787122b885d1de29b5b657 Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Sat, 21 Oct 2023 16:05:05 -0400 Subject: [PATCH] Use buffer-local comment-continue in comment-indent-new-line As the FIXME said, comment-indent-new-line was wiping out the value of comment-continue even if it had been set explicitly. Checking local-variable-p should be sufficient to fix this. This makes comment-indent-new-line work properly if comment-continue can't be recalculated from comment-start, such as if comment-continue is all whitespace. * lisp/newcomment.el (comment-indent-new-line): Don't set comment-continue to nil if it's local-variable-p. * test/lisp/newcomment-tests.el (local-comment-continue-in-comment-indent-new-line): Add a test. --- lisp/newcomment.el | 5 +++-- test/lisp/newcomment-tests.el | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/lisp/newcomment.el b/lisp/newcomment.el index 9ae7de70a0e..b217f700f22 100644 --- a/lisp/newcomment.el +++ b/lisp/newcomment.el @@ -1541,9 +1541,10 @@ comment-indent-new-line (cadr (assoc comment-style comment-styles)))) ;; Recreate comment-continue from comment-start. - ;; FIXME: wrong if comment-continue was set explicitly! ;; FIXME: use prev line's continuation if available. - (comment-continue nil)) + (comment-continue (if (local-variable-p 'comment-continue) + comment-continue + nil))) (comment-indent continuep)) (save-excursion (let ((pt (point))) diff --git a/test/lisp/newcomment-tests.el b/test/lisp/newcomment-tests.el index cb0f304c463..9851b4c2c45 100644 --- a/test/lisp/newcomment-tests.el +++ b/test/lisp/newcomment-tests.el @@ -36,4 +36,21 @@ test-uncomment-space-comment-continue (uncomment-region (point-min) (point-max)) (buffer-string)))))) +(ert-deftest local-comment-continue-in-comment-indent-new-line () + (with-temp-buffer + (setq-local comment-start "/* ") + (setq-local comment-end "*/") + (insert "foo") + (newline) + (insert "bar") + (forward-line -1) + (end-of-line) + (comment-region (point-min) (point-max)) + (should (equal (thing-at-point 'line) "/* foo\n")) + (comment-indent-new-line) + (should (equal (thing-at-point 'line) " * \n")) + (setq-local comment-continue " ") + (comment-indent-new-line) + (should (equal (thing-at-point 'line) " \n")))) + ;;; newcomment-tests.el ends here -- 2.39.3 --=-=-=--