branch: externals/phps-mode
commit 580298c39528509f61c36fa2228096de71639c91
Author: Christian Johansson <christ...@cvj.se>
Commit: Christian Johansson <christ...@cvj.se>

    Improved indentation of multi-line concatenated strings containing brackets
---
 phps-mode-indent.el           | 35 ++++++++++++++++++-----------------
 test/phps-mode-test-indent.el |  6 ++----
 2 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/phps-mode-indent.el b/phps-mode-indent.el
index 7658c79ad2..78e1e9abd7 100644
--- a/phps-mode-indent.el
+++ b/phps-mode-indent.el
@@ -1154,23 +1154,6 @@
                  new-indentation
                  (+ new-indentation 1)))
 
-               ;; LINE AFTER INCREASE IN BRACKETS
-               ;; array(
-               ;;     'here'
-               ;; or
-               ;; [[
-               ;;     'here'
-               ;; or
-               ;; if (something) {
-               ;;     echo 'here';
-               ((>= previous-bracket-level tab-width)
-                (setq
-                 match-type
-                 'line-after-increase-in-brackets)
-                (setq
-                 new-indentation
-                 (+ new-indentation tab-width)))
-
                ;; LINE AFTER LINE THAT ENDS AND STARTS A BRACKET BLOCK
                ;; ) {
                ;;     echo 'here'
@@ -1511,6 +1494,24 @@
                          new-indentation
                          first-concatenated-line-indent)))))
 
+
+               ;; LINE AFTER INCREASE IN BRACKETS
+               ;; array(
+               ;;     'here'
+               ;; or
+               ;; [[
+               ;;     'here'
+               ;; or
+               ;; if (something) {
+               ;;     echo 'here';
+               ((>= previous-bracket-level tab-width)
+                (setq
+                 match-type
+                 'line-after-increase-in-brackets)
+                (setq
+                 new-indentation
+                 (+ new-indentation tab-width)))
+
                ;; LINE AFTER CASE DEFINITION
                ;; case true:
                ;;     echo 'here';
diff --git a/test/phps-mode-test-indent.el b/test/phps-mode-test-indent.el
index 2e88a17f7b..1a6b7202f1 100644
--- a/test/phps-mode-test-indent.el
+++ b/test/phps-mode-test-indent.el
@@ -583,18 +583,16 @@
    "<?php\nif (true) {\n    $variable =\n        Object::\n        
method($variable2, true);\n    // Line comment\n    $variable['index'] = 
$variabl2->method2();\n}"
    "Mix of various types of statements and expressions")
 
-  ;; TODO Make this pass
   (phps-mode-test-indent--should-equal
    "<?php\nif (true) {\n    $html .= '<dt>'\n        . __(\n            
'Text',\n            'namespace'\n        )\n        . ':</dt><dd>'\n        . 
'<input type=\"hidden\" name=\"my_name['\n        . $variable . ']\" value=\"' 
. esc($myName) . '\" />'\n        . '<select class=\"my-class\" 
name=\"my_name['\n        . $variable2 . ']\">';\n    echo 'here';\n}\n"
    "Multi-line echo statement with HTML 1")
 
-  ;; TODO Make this pass
   (phps-mode-test-indent--should-equal
-   "<?php\nif (true) {\n    echo '<script type=\"text/javascript\">'\n    . 
'jQuery(document).ready(function() {'\n    . 
'jQuery(\"<option>\").val(\"my_value\").text(\"'\n    . __(\"Was here\", 
'namespace')\n    . '\").appendTo(\"select[name=\'key\']\");'\n    . 
'jQuery(\"<option>\").val(\"action\").text(\"'\n    . __(\"My action\", 
'namespace')\n    . '\").appendTo(\"select[name=\'anotherAction\']\");'\n    . 
'jQuery(\"<option>\").val(\"my_value2\").text(\"'\n    . __(\"My other action\ 
[...]
+   "<?php\nif (true) {\n    echo '<script type=\"text/javascript\">'\n        
. 'jQuery(document).ready(function() {'\n        . 
'jQuery(\"<option>\").val(\"my_value\").text(\"'\n        . __(\"Was here\", 
'namespace')\n        . '\").appendTo(\"select[name='key']\");'\n        . 
'jQuery(\"<option>\").val(\"action\").text(\"'\n        . __(\"My action\", 
'namespace')\n        . '\").appendTo(\"select[name='anotherAction']\");'\n     
   . 'jQuery(\"<option>\").val(\"my_value2\").text(\"'\ [...]
    "Multi-line echo statement with HTML markup 2")
 
   (phps-mode-test-indent--should-equal
-   "<?php\nif (true) {\n    echo '<script type=\"text/javascript\">'\n    . 
'jQuery(document).ready(function() { '\n    . 'window.open(\"'\n    . $url . 
'\", \"_blank\");'\n    . ' });</script>';\n}\n"
+   "<?php\nif (true) {\n    echo '<script type=\"text/javascript\">'\n        
. 'jQuery(document).ready(function() { '\n        . 'window.open(\"'\n        . 
$url . '\", \"_blank\");'\n        . ' });</script>';\n}"
    "Multi-line echo statement with HTML markup 3")
 
   ;; TODO Make this pass

Reply via email to