[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode 4e5be4f8f8 112/212: More indentation work for
From: |
Christian Johansson |
Subject: |
[elpa] externals/phps-mode 4e5be4f8f8 112/212: More indentation work for mixed PHP/HTML content |
Date: |
Wed, 26 Jan 2022 01:51:08 -0500 (EST) |
branch: externals/phps-mode
commit 4e5be4f8f8232c9e632a1f450c9450316b00e68f
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
More indentation work for mixed PHP/HTML content
---
phps-mode-indent.el | 43 ++++++++++++++++++++++++++++---------------
test/phps-mode-test-indent.el | 2 +-
2 files changed, 29 insertions(+), 16 deletions(-)
diff --git a/phps-mode-indent.el b/phps-mode-indent.el
index 85c6427bc8..239360b04f 100644
--- a/phps-mode-indent.el
+++ b/phps-mode-indent.el
@@ -68,49 +68,56 @@
"If STRING start with closing bracket, return it, otherwise return nil."
(phps-mode-indent--string-starts-with-regexp
string
- "[\t ]*\\([\]})]\\)"
- 1))
+ "[\t ]*\\(<\\?php[\t\n ]*\\)?\\([\]})]\\)"
+ 2))
(defun phps-mode-indent--string-starts-with-opening-bracket (string)
"If STRING start with opening bracket return it otherwise nil."
(phps-mode-indent--string-starts-with-regexp
string
- "[\t ]*\\([\[{(]\\)"
- 1))
+ "[\t ]*\\(<\\?php[\t\n ]*\\)?\\([\[{(]\\)"
+ 2))
(defun phps-mode-indent--string-starts-with-opening-doc-comment (string)
"Does STRING start with opening doc comment?"
(phps-mode-indent--string-starts-with-regexp
string
- "[\t ]*\\(/\\*\\*\\)"
- 1))
+ "[\t ]*\\(<\\?php[\t\n ]*\\)?\\(/\\*\\*\\)"
+ 2))
(defun phps-mode-indent--string-ends-with-assignment (string)
"If STRING end with terminus, return it, otherwise return nil."
(phps-mode-indent--string-ends-with-regexp
string
- "\\(=>?\\)[\t ]*"
+ "\\(=>?\\)[\t ]*\\(\\?>[\t\n ]*\\)?"
1))
(defun phps-mode-indent--string-ends-with-closing-bracket (string)
"If STRING end with closing bracket, return it, otherwise nil."
(phps-mode-indent--string-ends-with-regexp
string
- "\\([\]})]\\)[\t ]*"
+ "\\([\]})]\\)[\t ]*\\(\\?>[\t\n ]*\\)?"
+ 1))
+
+(defun phps-mode-indent--string-ends-with-closing-doc-comment (string)
+ "If STRING end with closing doc comment, return it, otherwise nil."
+ (phps-mode-indent--string-ends-with-regexp
+ string
+ "\\(\\*/\\)[\t ]*\\(\\?>[\t\n ]*\\)?"
1))
(defun phps-mode-indent--string-ends-with-opening-bracket (string)
"If STRING end with opening bracket, return it, otherwise nil."
(phps-mode-indent--string-ends-with-regexp
string
- "\\([\[{(]\\)[\t ]*"
+ "\\([\[{(]\\)[\t ]*\\(\\?>[\t\n ]*\\)?"
1))
(defun phps-mode-indent--string-ends-with-terminus (string)
"If STRING end with terminus, return it, otherwise return nil."
(phps-mode-indent--string-ends-with-regexp
string
- "\\(;\\|,\\)[\t ]*"
+ "\\(;\\|,\\)[\t ]*\\(\\?>[\t\n ]*\\)?"
1))
@@ -215,6 +222,9 @@
(previous-line-starts-with-opening-doc-comment
(phps-mode-indent--string-starts-with-opening-doc-comment
previous-line-string))
+ (previous-line-starts-with-closing-doc-comment
+ (phps-mode-indent--string-ends-with-closing-doc-comment
+ previous-line-string))
(previous-line-ends-with-assignment
(phps-mode-indent--string-ends-with-assignment
previous-line-string))
@@ -533,10 +543,11 @@
(setq
new-indentation
first-concatenated-line-indent))
- ;; This is the first concatenated line so we indent it
- (setq
- new-indentation
- (+ new-indentation tab-width)))
+ (unless (= previous-bracket-level tab-width)
+ ;; This is the first concatenated line so we indent it
+ (setq
+ new-indentation
+ (+ new-indentation tab-width))))
;; Reset point
(goto-char old-point)))
@@ -660,7 +671,9 @@
(when current-line-starts-with-closing-bracket
(setq new-indentation (- new-indentation tab-width)))
- (when previous-line-starts-with-opening-doc-comment
+ (when (and
+ previous-line-starts-with-opening-doc-comment
+ (not previous-line-starts-with-closing-doc-comment))
(setq new-indentation (+ new-indentation 1)))
(when (and
diff --git a/test/phps-mode-test-indent.el b/test/phps-mode-test-indent.el
index 211c2cbb3a..907d8e51b0 100644
--- a/test/phps-mode-test-indent.el
+++ b/test/phps-mode-test-indent.el
@@ -122,7 +122,7 @@
"Concatenated single-quoted-string spanning multiple-lines inside function
2")
(phps-mode-test-indent--should-equal
- "<?php\necho <<<EOD\nExample of string\nspanning multiple lines\nusing
heredoc syntax.\nEOD;\n"
+ "<?php\necho <<<EOD\nExample of string\nspanning multiple lines\nusing
heredoc syntax\nEOD;\n"
"Multi-line HEREDOC string outside assignment")
(phps-mode-test-indent--should-equal
- [elpa] externals/phps-mode 35c9b0fd1c 003/212: Imenu generated correctly for one case, (continued)
- [elpa] externals/phps-mode 35c9b0fd1c 003/212: Imenu generated correctly for one case, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 8652f7162e 014/212: Started on bookkeeping generation via parser SDT, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode a0d2abc2ee 009/212: More working on imenu generation via parser SDT, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode c7e308a13f 024/212: Added SDT foreach($x as $key => $value), Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode d44e79ad03 028/212: More work on grammar SDT, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode f79b6118a4 087/212: Optimization of string indentation function, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode b94ee63396 089/212: More work on indentation, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode d8503c70bb 106/212: Passing indent tests for switch case, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 4f20de353e 109/212: Passed indent tests for PSR-2, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 6655248e86 105/212: Passing indent test for regular switch statement, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 4e5be4f8f8 112/212: More indentation work for mixed PHP/HTML content,
Christian Johansson <=
- [elpa] externals/phps-mode ff62626f48 110/212: Passing indent test for square bracket array, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 50d006852c 129/212: Fixed issue with indent being dependent on position of point on current line, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 3de8eff9f1 114/212: More wrestling with indentation, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode d3b5a85b70 001/212: Using property list as basis for AST, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode a80c12ef14 005/212: Passing imenu-generation for file with multiple namespaces, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 0071b40aae 007/212: Syntax coloring is now in separate file, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 1cc4aed616 016/212: Passing first bookkeeping test via generation via parser SDT, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode b3b27951bd 015/212: More work on bookkeeping, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 395a4ed045 036/212: Started on bookkeeping via parser SDT for properties, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 69341c9709 039/212: More working on bookkeeping of class properties via parser SDT, Christian Johansson, 2022/01/26