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

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

[elpa] externals/phps-mode 3de8eff9f1 114/212: More wrestling with inden


From: Christian Johansson
Subject: [elpa] externals/phps-mode 3de8eff9f1 114/212: More wrestling with indentation
Date: Wed, 26 Jan 2022 01:51:08 -0500 (EST)

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

    More wrestling with indentation
---
 phps-mode-indent.el           | 35 +++++++++++++++++++++++++++++------
 test/phps-mode-test-indent.el |  6 +++---
 2 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/phps-mode-indent.el b/phps-mode-indent.el
index 1cba4f9e03..5d3f91512b 100644
--- a/phps-mode-indent.el
+++ b/phps-mode-indent.el
@@ -306,6 +306,34 @@
                       previous-line-string))
                 (setq new-indentation (+ new-indentation tab-width)))
 
+              ;; $var = 'A line' .
+              ;;     'something';
+              (when (and
+                     (string-match-p
+                      "^[\t ]*$[a-zA-Z0-9]+[\t ]*="
+                      previous-line-string)
+                     (not
+                      (string-match-p
+                       ";[\t ]*$"
+                       previous-line-string)))
+                (setq
+                 previous-bracket-level
+                 (+ previous-bracket-level tab-width)))
+
+              ;; echo 'Something' .
+              ;;     'something';
+              (when (and
+                     (string-match-p
+                      "^[\t ]*\\(echo\\|print\\|return\\|die\\)"
+                      previous-line-string)
+                     (not
+                      (string-match-p
+                       ";[\t ]*$"
+                       previous-line-string)))
+                (setq
+                 previous-bracket-level
+                 (+ previous-bracket-level tab-width)))
+
               ;; else
               ;;     echo 'Something';
               ;; or
@@ -542,12 +570,7 @@
                         ;; We use previous concatenated lines indent
                         (setq
                          new-indentation
-                         first-concatenated-line-indent))
-                    (unless (= previous-bracket-level tab-width)
-                      ;; This is the first concatenated line so we indent it
-                      (setq
-                       new-indentation
-                       (+ new-indentation tab-width))))
+                         first-concatenated-line-indent)))
 
                   ;; Reset point
                   (goto-char old-point)))
diff --git a/test/phps-mode-test-indent.el b/test/phps-mode-test-indent.el
index 907d8e51b0..9afe572640 100644
--- a/test/phps-mode-test-indent.el
+++ b/test/phps-mode-test-indent.el
@@ -82,11 +82,11 @@
    "Multi-line NOWDOC string")
 
   (phps-mode-test-indent--should-equal
-   "<?php\n$var = \"A line\nmore text here\nlast line here\";"
+   "<?php\n$var = \"A line\n    more text here\n    last line here\";"
    "Multi-line double-quoted string")
 
   (phps-mode-test-indent--should-equal
-   "<?php\n$var = 'A line\nmore text here\nlast line here';"
+   "<?php\n$var = 'A line\n    more text here\n    last line here';"
    "Multi-line single-quoted string")
 
   (phps-mode-test-indent--should-equal
@@ -170,7 +170,7 @@
    "Assignment with square bracketed array")
 
   (phps-mode-test-indent--should-equal
-   "<?php\n$options = array(\n    'blaha' .\n        'blaha',\n    123,\n    
'blaha'\n);"
+   "<?php\n$options = array(\n    'blaha' .\n    'blaha',\n    123,\n    
'blaha'\n);"
    "Assignment with square bracketed array")
 
   (phps-mode-test-indent--should-equal



reply via email to

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