From: Mauro Aranda <maurooaranda@gmail.com>
To: 34245@debbugs.gnu.org
Cc: "積丹尼 Dan Jacobson" <jidanni@jidanni.org>
Subject: bug#34245: perl mode aligns code with comments
Date: Thu, 20 Oct 2022 08:51:32 -0300 [thread overview]
Message-ID: <eb9e3bc2-bbe8-ca5b-ff48-cefda74d9c29@gmail.com> (raw)
In-Reply-To: <871s4vjywa.fsf@jidanni.org>
[-- Attachment #1: Type: text/plain, Size: 556 bytes --]
severity 34245 minor
tags 34245 patch
quit
積丹尼 Dan Jacobson <jidanni@jidanni.org> writes:
> In perl mode, a TAB on the second line below causes
>
> my @genres = ( #["match", "BUT NOT"]
> ["Rainbow.*Taiwan|Taiwan.*Rainbow"],
>
> But wiser would be like perltidy does:
>
> my @genres = ( #["match", "BUT NOT"]
> ["Rainbow.*Taiwan|Taiwan.*Rainbow"],
I don't know why Debbugs marked this as a wishlist, it looks like a bug
to me.
Patch attached.
[-- Attachment #2: 0001-Fix-perl-mode-indentation-after-a-hanging-paren.patch --]
[-- Type: text/x-patch, Size: 2098 bytes --]
From a50ef6c2f08b8648f26e5fcf29c084c1449cb093 Mon Sep 17 00:00:00 2001
From: Mauro Aranda <maurooaranda@gmail.com>
Date: Thu, 20 Oct 2022 08:41:42 -0300
Subject: [PATCH] Fix perl-mode indentation after a hanging paren
* lisp/progmodes/perl-mode.el (perl-hanging-paren-p): Allow
comments. (Bug#34245)
* test/lisp/progmodes/perl-mode-tests.el (perl-test-bug-34245): New
test.
---
lisp/progmodes/perl-mode.el | 2 +-
test/lisp/progmodes/perl-mode-tests.el | 17 +++++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el
index c5d5d703fc..ef932f2ad8 100644
--- a/lisp/progmodes/perl-mode.el
+++ b/lisp/progmodes/perl-mode.el
@@ -968,7 +968,7 @@ perl-continuation-line-p
(defun perl-hanging-paren-p ()
"Non-nil if we are right after a hanging parenthesis-like char."
- (and (looking-at "[ \t]*$")
+ (and (looking-at "[ \t]*\\(?:#.*\\)?$")
(save-excursion
(skip-syntax-backward " (") (not (bolp)))))
diff --git a/test/lisp/progmodes/perl-mode-tests.el b/test/lisp/progmodes/perl-mode-tests.el
index 91f1db23d6..5fb0ed9d53 100644
--- a/test/lisp/progmodes/perl-mode-tests.el
+++ b/test/lisp/progmodes/perl-mode-tests.el
@@ -28,6 +28,23 @@ perl-test-lock
(font-lock-ensure (point-min) (point-max))
(should (equal (get-text-property 4 'face) 'font-lock-variable-name-face))))
+(ert-deftest perl-test-bug-34245 ()
+ "Test correct indentation after a hanging paren, with and without comments."
+ (with-temp-buffer
+ (perl-mode)
+ (insert "my @foo = (\n\"bar\",\n\"baz\",\n);")
+ (insert "\n\n")
+ (insert "my @ofoo = (\t\t# A comment.\n\"obar\",\n\"obaz\",\n);")
+ (indent-region (point-min) (point-max))
+ (goto-char (point-min))
+ (forward-line)
+ (skip-chars-forward " \t")
+ (should (equal (current-column) perl-indent-level))
+ (search-forward "# A comment.")
+ (forward-line)
+ (skip-chars-forward " \t")
+ (should (equal (current-column) perl-indent-level))))
+
;;;; Re-use cperl-mode tests
(defvar cperl-test-mode)
--
2.34.1
next prev parent reply other threads:[~2022-10-20 11:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-29 14:56 bug#34245: perl mode aligns code with comments 積丹尼 Dan Jacobson
2022-10-20 11:51 ` Mauro Aranda [this message]
2023-09-06 22:15 ` Stefan Kangas
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=eb9e3bc2-bbe8-ca5b-ff48-cefda74d9c29@gmail.com \
--to=maurooaranda@gmail.com \
--cc=34245@debbugs.gnu.org \
--cc=jidanni@jidanni.org \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).