* bug#34245: perl mode aligns code with comments
@ 2019-01-29 14:56 積丹尼 Dan Jacobson
2022-10-20 11:51 ` Mauro Aranda
0 siblings, 1 reply; 3+ messages in thread
From: 積丹尼 Dan Jacobson @ 2019-01-29 14:56 UTC (permalink / raw)
To: 34245
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"],
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#34245: perl mode aligns code with comments
2019-01-29 14:56 bug#34245: perl mode aligns code with comments 積丹尼 Dan Jacobson
@ 2022-10-20 11:51 ` Mauro Aranda
2023-09-06 22:15 ` Stefan Kangas
0 siblings, 1 reply; 3+ messages in thread
From: Mauro Aranda @ 2022-10-20 11:51 UTC (permalink / raw)
To: 34245; +Cc: 積丹尼 Dan Jacobson
[-- 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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* bug#34245: perl mode aligns code with comments
2022-10-20 11:51 ` Mauro Aranda
@ 2023-09-06 22:15 ` Stefan Kangas
0 siblings, 0 replies; 3+ messages in thread
From: Stefan Kangas @ 2023-09-06 22:15 UTC (permalink / raw)
To: Mauro Aranda; +Cc: 34245-done, 積丹尼 Dan Jacobson
Version: 30.1
Mauro Aranda <maurooaranda@gmail.com> writes:
> 積丹尼 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.
Thanks, pushed to master as commit 2a8f458719a.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-09-06 22:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-29 14:56 bug#34245: perl mode aligns code with comments 積丹尼 Dan Jacobson
2022-10-20 11:51 ` Mauro Aranda
2023-09-06 22:15 ` Stefan Kangas
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.