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

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

[elpa] externals/phps-mode 426380c: Improved indentation for cases with


From: Christian Johansson
Subject: [elpa] externals/phps-mode 426380c: Improved indentation for cases with mixed HTML and PHP
Date: Thu, 26 Sep 2019 10:54:46 -0400 (EDT)

branch: externals/phps-mode
commit 426380c4f7b8b52fd343dac0cf804f1989051094
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>

    Improved indentation for cases with mixed HTML and PHP
---
 phps-mode-functions.el      | 9 ++++++++-
 phps-mode-test-functions.el | 2 +-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/phps-mode-functions.el b/phps-mode-functions.el
index ea17a50..5c858a8 100644
--- a/phps-mode-functions.el
+++ b/phps-mode-functions.el
@@ -960,7 +960,8 @@
                         (setq column-level-start 0))
 
                       ;; Inline HTML should have zero indent
-                      (when first-token-is-inline-html
+                      (when (and first-token-is-inline-html
+                                 (not inline-html-is-whitespace))
                         (phps-mode-debug-message
                          (message "Setting column-level to inline HTML indent: 
%s" inline-html-indent-start))
                         (setq column-level-start inline-html-indent-start))
@@ -1064,6 +1065,12 @@
                                (equal token 'T_INLINE_HTML)
                                (not inline-html-is-whitespace)
                                (> token-end-line-number 
token-start-line-number))
+
+                          (setq inline-html-is-whitespace
+                                (not (null
+                                      (string-match "[\n\C-m][ \t]+$" 
(substring string (1- token-start) (1- token-end))))))
+                          (phps-mode-debug-message
+                           (message "Trailing inline html line is whitespace: 
%s" inline-html-is-whitespace))
                           (phps-mode-debug-message
                            (message "Setting first-token-is-inline-html to 
true since last token on line is inline-html and spans several lines"))
                           (setq first-token-is-inline-html t))))
diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el
index 2abc3d4..73827d4 100644
--- a/phps-mode-test-functions.el
+++ b/phps-mode-test-functions.el
@@ -274,7 +274,7 @@
     "<html>\n    <head>\n        <?php echo $title; ?>\n    </head>\n    
<body>\n    <?php\n\n    if ($myTest) {\n        doSomething();\n    }\n\n    
?>\n    </body>\n</html>"
     "A mixed HTML and PHP file."
     ;; (message "Indent: %s" (phps-mode-test-hash-to-list 
(phps-mode-functions-get-lines-indent)))
-    (should (equal '((1 (0 0)) (2 (1 0)) (3 (2 0)) (4 (1 0)) (5 (1 0)) (6 (2 
0)) (7 (0 0)) (8 (0 0)) (9 (1 0)) (10 (0 0)) (11 (0 0)) (12 (0 0)) (13 (1 0)) 
(14 (0 0))) (phps-mode-test-hash-to-list 
(phps-mode-functions-get-lines-indent)))))
+    (should (equal '((1 (0 0)) (2 (1 0)) (3 (2 0)) (4 (1 0)) (5 (1 0)) (6 (0 
0)) (7 (0 0)) (8 (0 0)) (9 (1 0)) (10 (0 0)) (11 (0 0)) (12 (0 0)) (13 (1 0)) 
(14 (0 0))) (phps-mode-test-hash-to-list 
(phps-mode-functions-get-lines-indent)))))
    )
 
   )



reply via email to

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