From 711f908f5d7ce348e28e5640c83d1b0d024b65ca Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Fri, 16 Sep 2022 13:05:54 +0200 Subject: [PATCH] Fix cperl list indentation problem * lisp/progmodes/cperl-mode.el (cperl-calculate-indent): Indent foo:bar() in lists correctly (bug#57829). --- lisp/progmodes/cperl-mode.el | 2 +- .../cperl-mode-resources/cperl-indents.erts | 26 +++++++++++++++++++ test/lisp/progmodes/cperl-mode-tests.el | 3 +++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 test/lisp/progmodes/cperl-mode-resources/cperl-indents.erts diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el index a3995e2969d..85229250ee0 100644 --- a/lisp/progmodes/cperl-mode.el +++ b/lisp/progmodes/cperl-mode.el @@ -3016,7 +3016,7 @@ and closing parentheses and brackets." ;; Now it is a hash reference (+ cperl-indent-level cperl-close-paren-offset)) ;; Labels do not take :: ... - (if (looking-at "\\(\\w\\|_\\)+[ \t]*:") + (if (looking-at "\\(\\w\\|_\\)+[ \t]*:[^:]") (if (> (current-indentation) cperl-min-label-indent) (- (current-indentation) cperl-label-offset) ;; Do not move `parse-data', this should diff --git a/test/lisp/progmodes/cperl-mode-resources/cperl-indents.erts b/test/lisp/progmodes/cperl-mode-resources/cperl-indents.erts new file mode 100644 index 00000000000..6b874ffaa1f --- /dev/null +++ b/test/lisp/progmodes/cperl-mode-resources/cperl-indents.erts @@ -0,0 +1,26 @@ +Code: + (lambda () + (cperl-mode) + (indent-region (point-min) (point-max))) + +Name: cperl-indent1 + +=-= +{ + print "", + "", + foo::bar(), + ""; +} +=-=-= + +Name: cperl-indents1 + +=-= +{ + print "", + "", + foobar(), + ""; +} +=-=-= diff --git a/test/lisp/progmodes/cperl-mode-tests.el b/test/lisp/progmodes/cperl-mode-tests.el index 7eb2d9be756..db3feec93ab 100644 --- a/test/lisp/progmodes/cperl-mode-tests.el +++ b/test/lisp/progmodes/cperl-mode-tests.el @@ -1103,4 +1103,7 @@ as a regex." (funcall cperl-test-mode) (should-not (nth 3 (syntax-ppss 3))))) +(ert-deftest test-indentation () + (ert-test-erts-file (ert-resource-file "cperl-indents.erts"))) + ;;; cperl-mode-tests.el ends here -- 2.39.2