; cperl-mode.el: Indent labels only in code (Bug#79271)

* lisp/progmodes/cperl-mode.el (cperl-indent-line): Make sure that
labels are indented in code only

* test/lisp/progmodes/cperl-mode-resources/cperl-indents.erts: Two
new testcases for non-indentable "labels" in a regex pattern and a
qw list
This commit is contained in:
Harald Jörg 2025-08-22 12:42:00 +02:00
parent 6571b632ed
commit 384483e263
2 changed files with 23 additions and 0 deletions

View file

@ -2726,6 +2726,7 @@ PARSE-DATA is used to save status between calls in a loop."
(if (listp indent) (setq indent (car indent)))
(cond ((and (looking-at (rx (sequence (eval cperl--label-rx)
(not (in ":")))))
(null (get-text-property (point) 'syntax-type))
(not (looking-at (rx (eval cperl--false-label-rx)))))
(and (> indent 0)
(setq indent (max cperl-min-label-indent

View file

@ -123,3 +123,25 @@ sub foo (
return $a + $b + $in1;
}
=-=-=
Name: cperl-false-label-in-regex
=-=
# -*- mode: cperl -*-
# John Ciolfi reported as Bug#79271
my $str =~ s/^
(Field1: [^\n]+) \s*
Field2: \s* (\S+) \s*
//xsm;
=-=-=
Name: cperl-false-label-in-qw
=-=
# Related to cperl-false-label-in-regex / Bug#79271
my @chunks = qw(
sub
LABEL:
more words
);
=-=-=