From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: haj@posteo.de (Harald =?UTF-8?Q?J=C3=B6rg?=) Newsgroups: gmane.emacs.bugs Subject: bug#19709: [PATCH] Verify that indentation works with current cperl-mode Date: Wed, 04 Nov 2020 21:01:33 +0100 Message-ID: <87361ouc0y.fsf@hajtower> References: 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="18155"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) To: 19709@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Nov 04 21:02:42 2020 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 1kaOzR-0004ce-LV for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 04 Nov 2020 21:02:41 +0100 Original-Received: from localhost ([::1]:33844 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaOzQ-0007hn-Jl for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 04 Nov 2020 15:02:40 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40092) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaOyo-0006x3-EX for bug-gnu-emacs@gnu.org; Wed, 04 Nov 2020 15:02:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:39130) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kaOyo-0003p4-4N for bug-gnu-emacs@gnu.org; Wed, 04 Nov 2020 15:02:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kaOyo-0005t1-0t for bug-gnu-emacs@gnu.org; Wed, 04 Nov 2020 15:02:02 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: Resent-From: haj@posteo.de (Harald =?UTF-8?Q?J=C3=B6rg?=) Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 04 Nov 2020 20:02:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 19709 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed Original-Received: via spool by 19709-submit@debbugs.gnu.org id=B19709.160452010622605 (code B ref 19709); Wed, 04 Nov 2020 20:02:01 +0000 Original-Received: (at 19709) by debbugs.gnu.org; 4 Nov 2020 20:01:46 +0000 Original-Received: from localhost ([127.0.0.1]:50676 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kaOyY-0005sX-8n for submit@debbugs.gnu.org; Wed, 04 Nov 2020 15:01:46 -0500 Original-Received: from mout01.posteo.de ([185.67.36.65]:56337) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kaOyV-0005sG-Ag for 19709@debbugs.gnu.org; Wed, 04 Nov 2020 15:01:45 -0500 Original-Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id 67A17160060 for <19709@debbugs.gnu.org>; Wed, 4 Nov 2020 21:01:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1604520096; bh=XZA7Y4ZVF/17Anzq+g1oxAjRn2cQs7yItlZV3PvT8Fg=; h=From:To:Subject:Date:From; b=NF30K+Dz3gSCgbkb81Hs3KiM2nH9g6iBaFVkPINFoweKtJ4uuvUnvDzWv67sNUAYG dgDNd0qKOEmkYtcAi5FrOrQy94mZ7JocRoAUAglnR5xJliqIA7Qvbid2XGgvfyafUS yV6XFJ/qMAwU8e6bZfaWMJWSpNa1qktzIof+VYXdoBKAEyzqvb96QH4ScRTRca0cjy Fw4guUS2/QjiFz+42EcqyIZw4patPI5fpiB4kP1yvUS+lbNIx53R7T/+Wzdg9v/p26 mO1AU1ZwVeaKT013scyQ4jDzAUnEQi92eLdpk6SlaVhpshfhI+KLEcveh/b524i2ND GXCAh4O679Kpw== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4CRHbf1jJjz6tmY for <19709@debbugs.gnu.org>; Wed, 4 Nov 2020 21:01:34 +0100 (CET) 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" Xref: news.gmane.io gmane.emacs.bugs:192684 Archived-At: --=-=-= Content-Type: text/plain This bug apparently can no longer be reproduced. Using quick'n'dirty bisection (avoiding recompilations of the whole source tree) I could track the fix back to commit 1bcbcb7e, "lisp/progmodes/cperl-mode.el: Merge from Jonathan Rockway's version" by Stefan Monnier, 21st Dec 2017. This makes sense since this commit introduced a new function 'cperl-calculate-indent' to cperl-mode.el. The patch adds a test to verify correct behavior, and also adds the relevant variable cperl-close-paren-offset (which is explicitly set in the bug report) to the scope of the cperl-set-style setting "PBP". This variable is documented in the book, but wasn't included yet. -- Cheers, haj --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-cperl-mode-Indentation-of-follows-customisation.patch Content-Description: Indentation obeys customisation >From 91761ee3e83cfad9ccabdd75dd364e9bc84db145 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harald=20J=C3=B6rg?= Date: Wed, 4 Nov 2020 18:39:24 +0100 Subject: [PATCH] ; cperl-mode: Indentation of ')' follows customisation * test/lisp/progmodes/cperl-mode-tests.el (cperl-bug19709): New test to verify correct indentation of closing parentheses (Bug#19709). * test/lisp/progmodes/cperl-mode-resources/cperl-bug-19709.pl: New test case with code from the bug report. * lisp/progmodes/cperl-mode.el (cperl-style-alist): Add cperl-close-paren-offset to the settings for PBP style. * test/lisp/progmodes/cperl-mode-resources/cperl-indent-styles.pl: Add a new test clause for cperl-close-paren-offset. --- lisp/progmodes/cperl-mode.el | 1 + .../cperl-mode-resources/cperl-bug-19709.pl | 25 ++++++++++++ .../cperl-indent-styles.pl | 10 +++++ test/lisp/progmodes/cperl-mode-tests.el | 38 +++++++++++++++++++ 4 files changed, 74 insertions(+) create mode 100644 test/lisp/progmodes/cperl-mode-resources/cperl-bug-19709.pl diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el index 6178cdfc9b..d5b30025e7 100644 --- a/lisp/progmodes/cperl-mode.el +++ b/lisp/progmodes/cperl-mode.el @@ -5983,6 +5983,7 @@ cperl-style-alist (cperl-continued-brace-offset . 0) (cperl-label-offset . -2) (cperl-continued-statement-offset . 4) + (cperl-close-paren-offset . -4) (cperl-extra-newline-before-brace . nil) (cperl-extra-newline-before-brace-multiline . nil) (cperl-merge-trailing-else . nil) diff --git a/test/lisp/progmodes/cperl-mode-resources/cperl-bug-19709.pl b/test/lisp/progmodes/cperl-mode-resources/cperl-bug-19709.pl new file mode 100644 index 0000000000..f7c51a2ce5 --- /dev/null +++ b/test/lisp/progmodes/cperl-mode-resources/cperl-bug-19709.pl @@ -0,0 +1,25 @@ +# -------- bug#19709: input -------- +my $a = func1( + Module::test() + ); + +my $b = func2( + test() +); + +my $c = func3( + Module::test(), +); +# -------- bug#19709: expected output -------- +my $a = func1( + Module::test() +); + +my $b = func2( + test() +); + +my $c = func3( + Module::test(), +); +# -------- bug#19709: end -------- diff --git a/test/lisp/progmodes/cperl-mode-resources/cperl-indent-styles.pl b/test/lisp/progmodes/cperl-mode-resources/cperl-indent-styles.pl index 0832f86828..371b19b730 100644 --- a/test/lisp/progmodes/cperl-mode-resources/cperl-indent-styles.pl +++ b/test/lisp/progmodes/cperl-mode-resources/cperl-indent-styles.pl @@ -42,3 +42,13 @@ } } # -------- PBP uncuddle else: end -------- + +# -------- PBP closing paren offset: input -------- +my $a = func1( + Module::test() + ); +# -------- PBP closing paren offset: expected output -------- +my $a = func1( + Module::test() +); +# -------- PBP closing paren offset: end -------- diff --git a/test/lisp/progmodes/cperl-mode-tests.el b/test/lisp/progmodes/cperl-mode-tests.el index 2977f10813..a262db3136 100644 --- a/test/lisp/progmodes/cperl-mode-tests.el +++ b/test/lisp/progmodes/cperl-mode-tests.el @@ -249,6 +249,44 @@ cperl-bug30393 (setq got (concat "test case " name ":\n" (buffer-string))) (should (equal got expected)))))))) +(ert-deftest cperl-bug19709 () + "Verify that indentation of closing paren works as intended. +Note that Perl mode has no setting for close paren offset, per +documentation it does the right thing anyway." + (let ((file (ert-resource-file "cperl-bug-19709.pl"))) + (with-temp-buffer + (insert-file-contents file) + (goto-char (point-min)) + (while (re-search-forward + (concat "^# ?-+ \\_<\\(?1:.+?\\)\\_>: input ?-+\n" + "\\(?2:\\(?:.*\n\\)+?\\)" + "# ?-+ \\1: expected output ?-+\n" + "\\(?3:\\(?:.*\n\\)+?\\)" + "# ?-+ \\1: end ?-+") + nil t) + (let ((name (match-string 1)) + (code (match-string 2)) + (expected (match-string 3)) + got) + (with-temp-buffer + (insert code) + (funcall cperl-test-mode) + (setq-local + ;; settings from the bug report + cperl-indent-level 4 + cperl-indent-parens-as-block t + cperl-close-paren-offset -4 + ;; same, adapted for per-mode + perl-indent-level 4 + perl-indent-parens-as-block t) + (goto-char (point-min)) + (while (null (eobp)) + (cperl-indent-command) + (next-line)) + (setq expected (concat "test case " name ":\n" expected)) + (setq got (concat "test case " name ":\n" (buffer-string))) + (should (equal got expected)))))))) + (ert-deftest cperl-bug37127 () "Verify that closing a paren in a regex goes without a message. Also check that the message is issued if the regex terminator is -- 2.20.1 --=-=-=--