branch: externals/phps-mode
commit b86dd54daa5745f1f779e767f4f48a3bbdd9adb4
Author: Christian Johansson <[email protected]>
Commit: Christian Johansson <[email protected]>
Indentation now supports new lexer token T_INLINE HTML
---
phps-mode-functions.el | 15 +++++++++++++++
phps-mode-test-functions.el | 3 +--
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/phps-mode-functions.el b/phps-mode-functions.el
index 9603726..7b4b935 100644
--- a/phps-mode-functions.el
+++ b/phps-mode-functions.el
@@ -75,6 +75,7 @@
(in-heredoc-started-this-line nil)
(in-heredoc-ended-this-line nil)
(in-inline-control-structure nil)
+ (first-token-is-inline-html nil)
(after-special-control-structure nil)
(after-special-control-structure-token nil)
(after-extra-special-control-structure nil)
@@ -254,6 +255,11 @@
(when first-token-on-line
(setq first-token-is-nesting-decrease t)))
+ ;; Detect in inline-html
+ (when (and (equal token 'T_INLINE_HTML)
+ first-token-on-line)
+ (setq first-token-is-inline-html t))
+
;; Keep track of when we are inside a class definition
(if in-class-declaration
(if (string= token "{")
@@ -532,6 +538,10 @@
in-heredoc-ended-this-line)
(setq column-level-start 0))
+ ;; Inline HTML should have zero indent
+ (when first-token-is-inline-html
+ (setq column-level-start 0))
+
;; Save line indent
(when phps-mode-functions-verbose
@@ -580,6 +590,10 @@
in-heredoc-ended-this-line)
(setq column-level-end 0))
+ ;; Inline HTML should have no indent
+ (when (equal token 'T_INLINE_HTML)
+ (setq column-level-end 0))
+
;; (message "Token %s starts at %s and ends at %s
indent %s %s" next-token token-start-line-number token-end-line-number
column-level-end tuning-level)
;; Indent doc-comment lines with 1 tuning
@@ -617,6 +631,7 @@
(when (> token-start-line-number last-line-number)
(setq first-token-on-line t)
(setq first-token-is-nesting-decrease nil)
+ (setq first-token-is-inline-html nil)
(setq in-assignment-level 0)
(setq in-class-declaration-level 0)
(setq class-declaration-started-this-line nil)
diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el
index 995bcab..29c1f35 100644
--- a/phps-mode-test-functions.el
+++ b/phps-mode-test-functions.el
@@ -36,7 +36,6 @@
(autoload 'phps-mode-test-hash-to-list "phps-mode-test")
(autoload 'should "ert")
-
(defun phps-mode-test-functions-get-lines-indent ()
"Test `phps-mode-functions-get-lines-indent' function."
@@ -371,7 +370,7 @@
(phps-mode-test-with-buffer
"<html><head><title><?php if ($myCondition) {\nif ($mySeconCondition)
{\necho $title3;\n\n}\n?>\n</title><body>Bla bla</body></html>"
"Curly bracket test 4"
- ;; (message "Tokens: %s" phps-mode-lexer-tokens)
+ (message "Tokens: %s" (phps-mode-lexer-get-tokens))
(goto-char 110)
(phps-mode-functions-indent-line)
(let ((buffer-contents (buffer-substring-no-properties (point-min)
(point-max))))