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

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

[elpa] externals/phps-mode 057aadd2f6 197/212: Improved indentation arou


From: Christian Johansson
Subject: [elpa] externals/phps-mode 057aadd2f6 197/212: Improved indentation around multi-line logical expressions
Date: Wed, 26 Jan 2022 01:51:26 -0500 (EST)

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

    Improved indentation around multi-line logical expressions
---
 phps-mode-indent.el           | 25 +++++++++++++++++++++++--
 test/phps-mode-test-indent.el |  8 ++++++--
 2 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/phps-mode-indent.el b/phps-mode-indent.el
index f3ee0198a4..7862f73b54 100644
--- a/phps-mode-indent.el
+++ b/phps-mode-indent.el
@@ -1290,7 +1290,28 @@
                         (setq
                          new-indentation
                          (phps-mode-indent--string-indentation
-                          reference-line)))
+                          reference-line))
+
+                        ;; $variable = (!empty($data['point1'])
+                        ;;         && $data['point2'] === 22)
+                        ;;     || (!empty($data['point3'])
+                        ;; or
+                        ;; $array = [
+                        ;;     'pointers' => (!empty($data['point1'])
+                        ;;         && $data['point2'] === 22)
+                        ;;     || (!empty($data['point3'])
+                        (when (or
+                               (string-match-p
+                                "^[\t ]*$[a-zA-Z0-9_]+[\t ]*[^=!]*=\\($\\|[\t 
]+.*[^,;]$\\)"
+                                reference-line)
+                               (string-match-p
+                                "=>[^,;]*$"
+                                reference-line))
+                          (setq
+                           new-indentation
+                           (+
+                            new-indentation
+                            tab-width))))
 
                     ;; (message "previous-line-string: %S" 
previous-line-string)
 
@@ -1304,7 +1325,7 @@
                             "^[\t ]*$[a-zA-Z0-9_]+[\t ]*[^=!]*=\\($\\|[\t 
]+.*[^,;]$\\)"
                             previous-line-string)
                            (string-match-p
-                            "=>[^,;]$"
+                            "=>[^,;]*$"
                             previous-line-string))
                       (setq
                        new-indentation
diff --git a/test/phps-mode-test-indent.el b/test/phps-mode-test-indent.el
index 15cb37c0c7..486df5dca5 100644
--- a/test/phps-mode-test-indent.el
+++ b/test/phps-mode-test-indent.el
@@ -565,10 +565,14 @@
    "<?php\n\nif (!defined('VARIABLE')) {\n    
exit;\n}\n\nrequire_once(CONSTANT . 'path');\n$variable = myFunction1(\n    
'argument1',\n    'argument2'\n);\n\nif (is_logged_in()) {\n    $variable = 
myFunction2(\n        'argument1',\n        'argument2'\n    );\n    
require_once(CONSTANT . 'string');\n}\n"
    "Mixed expressions and statements")
 
-  ;; TODO Make this pass outside of automatic test
   (phps-mode-test-indent--should-equal
    "<?php\n\n$array = [\n    'enabled' => (true\n        && false)\n        || 
true\n        || false,\n];\n"
-   "Multi-line logical expression in associate array")
+   "Multi-line logical expression in associative array")
+
+  ;; TODO Make this work outside of automatic test
+  (phps-mode-test-indent--should-equal
+   "<?php\n\n$array = [\n    'pointers' => (!empty($data['point1'])\n        
&& $data['point2'] === 22)\n        || (!empty($data['point3'])\n            && 
$data['point4'] === 33)\n        || (!empty($data['point4'])\n            && 
$data['point4'] === 44),\n    'arrows' =>\n        $data['arrows'],\n];\n"
+   "Another multi-line logical expression inside associative array")
 
   )
 



reply via email to

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