emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master bd86a6c4fde: perl-mode.el: Improve indent after hanging open-pare


From: Stefan Monnier
Subject: master bd86a6c4fde: perl-mode.el: Improve indent after hanging open-paren
Date: Fri, 5 Jul 2024 10:02:49 -0400 (EDT)

branch: master
commit bd86a6c4fde1aa42ea9e8b5434f0cb63f8d52684
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    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`.
---
 lisp/progmodes/perl-mode.el  | 9 +--------
 test/manual/indent/perl.perl | 4 ++++
 2 files changed, 5 insertions(+), 8 deletions(-)

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]