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

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

[elpa] externals/phps-mode 20ad1fae08 132/212: Improved indentation arro


From: Christian Johansson
Subject: [elpa] externals/phps-mode 20ad1fae08 132/212: Improved indentation arround multi-line object operators
Date: Wed, 26 Jan 2022 01:51:12 -0500 (EST)

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

    Improved indentation arround multi-line object operators
---
 phps-mode-indent.el           | 24 ++++++++++++++++++++----
 test/phps-mode-test-indent.el |  4 ++--
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/phps-mode-indent.el b/phps-mode-indent.el
index 4d5441e765..65b3ad8891 100644
--- a/phps-mode-indent.el
+++ b/phps-mode-indent.el
@@ -851,9 +851,12 @@
                ;; return myFunction(
                ;;     'expression');
                ;; echo 'here';
+               ;; or
+               ;; 'name' =>
+               ;;     $myObject->getName(),
+               ;; 'age' =>
                ((and
                  previous-line-ends-with-terminus
-                 (string= previous-line-ends-with-terminus ";")
                  (not
                   (string-match-p
                    "^[\t ]*\\(echo[\t ]+\\|print[\t ]+\\)"
@@ -877,7 +880,7 @@
                       (and
                        not-found
                        (search-backward-regexp
-                        "\\(;\\|{\\|(\\|)\\|=$\\|=[^>]\\|return\\|echo[\t 
]+\\|print[\t ]+\\|\n\\|<<<'?\"?[a-zA-Z0-9]+'?\"?\\)"
+                        "\\(;\\|{\\|(\\|)\\|=\\|return\\|echo[\t ]+\\|print[\t 
]+\\|\n\\|<<<'?\"?[a-zA-Z0-9]+'?\"?\\)"
                         nil
                         t))
                     (let ((match (match-string-no-properties 0)))
@@ -977,7 +980,17 @@
                           is-bracket-less-command))
                     (setq
                      new-indentation
-                     (- new-indentation tab-width))))
+                     (- new-indentation tab-width)))
+
+                  (when (and
+                         current-line-starts-with-closing-bracket
+                         (not previous-line-ends-with-opening-bracket)
+                         (>= previous-indentation tab-width))
+                    (setq
+                     new-indentation
+                     (- new-indentation tab-width)))
+
+                  )
 
                 (goto-char point))
 
@@ -1003,7 +1016,10 @@
                  (not previous-line-ends-with-opening-bracket)
                  (string-match-p
                   "->"
-                  previous-line-string))
+                  previous-line-string)
+                 (string-match-p
+                  "^[\t ]*->"
+                  current-line-string))
                 (let ((not-found t)
                       (started-chaining-on-this-line t)
                       (is-assignment)
diff --git a/test/phps-mode-test-indent.el b/test/phps-mode-test-indent.el
index c1c2510cfc..69c1c7a783 100644
--- a/test/phps-mode-test-indent.el
+++ b/test/phps-mode-test-indent.el
@@ -20,7 +20,7 @@
 (defun phps-mode-test-indent--indent-whole-buffer ()
   "Use alternative indentation of every line of buffer."
   (goto-char (point-min))
-  (indent-for-tab-command)
+  (execute-kbd-macro (kbd "TAB"))
   (while (search-forward "\n" nil t nil)
     ;; Go to random point on line
     (let ((line-min-position (line-beginning-position))
@@ -29,7 +29,7 @@
        (+
         line-min-position
         (random (- line-max-position line-min-position)))))
-    (indent-for-tab-command)))
+    (execute-kbd-macro (kbd "TAB"))))
 
 (defun phps-mode-test-indent--should-equal (string name)
   "Test indent of whole buffer containing STRING with NAME."



reply via email to

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