From: Stefan Monnier Date: Fri, 5 Jul 2024 14:02:39 +0000 (-0400) Subject: perl-mode.el: Improve indent after hanging open-paren X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=52252146c5cef86652bff1f05bac705fc8e85444;p=emacs.git perl-mode.el: Improve indent after hanging open-paren Make the indentation of the code right after an open paren/brace use the same rule as already used to indent the corresponding matching paren/brace. * lisp/progmodes/perl-mode.el (perl-calculate-indent): Use `perl-indent-new-calculate`s "virtual" indentation instead of approximating it with `current-indentation`. (cherry picked from commit bd86a6c4fde1aa42ea9e8b5434f0cb63f8d52684) --- diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el index 68685fb6625..ff71970d41b 100644 --- a/lisp/progmodes/perl-mode.el +++ b/lisp/progmodes/perl-mode.el @@ -1130,14 +1130,7 @@ Returns (parse-state) if line starts inside a string." ;; add the perl-brace-imaginary-offset. (progn (skip-chars-backward " \t") (if (bolp) 0 perl-brace-imaginary-offset)) - ;; If the openbrace is preceded by a parenthesized exp, - ;; move to the beginning of that; - ;; possibly a different line - (progn - (if (eq (preceding-char) ?\)) - (forward-sexp -1)) - ;; Get initial indentation of the line we are on. - (current-indentation))))))))) + (perl-indent-new-calculate 'virtual)))))))) (defun perl-backward-to-noncomment () "Move point backward to after the first non-white-space, skipping comments." diff --git a/test/manual/indent/perl.perl b/test/manual/indent/perl.perl index b44593da028..de76fffa262 100755 --- a/test/manual/indent/perl.perl +++ b/test/manual/indent/perl.perl @@ -5,6 +5,10 @@ sub add_funds($) { return 0; } +find ({ wanted => sub { + return; + }, follow => 1 }, '/tmp'); + # qw(...) is a quoted list of words, so we can and should indent its content! my @tutu = qw[ tata