emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/phps-mode b5f38a926f 05/15: More work on indentation ar


From: Christian Johansson
Subject: [elpa] externals/phps-mode b5f38a926f 05/15: More work on indentation around multi-line chained objects
Date: Fri, 4 Mar 2022 14:13:02 -0500 (EST)

branch: externals/phps-mode
commit b5f38a926fa9da3ce39826f321774611a5b25f33
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>

    More work on indentation around multi-line chained objects
---
 phps-mode-indent.el | 45 +++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 41 insertions(+), 4 deletions(-)

diff --git a/phps-mode-indent.el b/phps-mode-indent.el
index 75c81a545b..23c7c5e3f0 100644
--- a/phps-mode-indent.el
+++ b/phps-mode-indent.el
@@ -905,7 +905,10 @@
                       (started-chaining-on-this-line t)
                       (is-string-concatenation)
                       (is-bracket-less-command)
-                      (is-same-line-p t))
+                      (is-same-line-p t)
+                      (chaining-line)
+                      (reference-line)
+                      (chaining-was-this-line-p))
                   (while
                       (and
                        not-found
@@ -914,11 +917,20 @@
                         nil
                         t))
                     (let ((match (match-string-no-properties 0)))
+                      (message "match: %S" match)
                       (cond
 
                        ((string=
                          "->"
                          match)
+                        (setq
+                         chaining-was-this-line-p
+                         t)
+                        (setq
+                         chaining-line
+                         (buffer-substring-no-properties
+                          (line-beginning-position)
+                          (line-end-position)))
                         (setq
                          started-chaining-on-this-line
                          is-same-line-p))
@@ -926,6 +938,17 @@
                        ((string=
                          "\n"
                          match)
+                        (if chaining-was-this-line-p
+                            (progn
+                              (setq
+                               chaining-was-this-line-p
+                               nil)
+                              (setq
+                               reference-line
+                               chaining-line))
+                          (setq
+                           reference-line
+                           nil))
                         (setq
                          is-same-line-p
                          nil))
@@ -950,7 +973,13 @@
                           match)
                          (string=
                           "}"
+                          match)
+                         (string=
+                          "{"
                           match))
+                        (setq
+                         reference-line
+                         nil)
                         (setq
                          not-found
                          nil))
@@ -978,9 +1007,17 @@
                          (not is-string-concatenation)
                          (not started-chaining-on-this-line)
                          (not is-bracket-less-command))
-                    (setq
-                     new-indentation
-                     (+ new-indentation tab-width)))))
+                    (if reference-line
+                        (progn
+                          (phps-mode-debug-message
+                           (message "reference-line: %S" reference-line))
+                          (setq
+                           new-indentation
+                           (phps-mode-indent--string-indentation
+                            reference-line)))
+                      (setq
+                       new-indentation
+                       (+ new-indentation tab-width))))))
 
                ;; LINE AFTER OPENING HEREDOC/NOWDOC
                ;; echo <<<VAR



reply via email to

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