[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode b94ee63396 089/212: More work on indentation
From: |
Christian Johansson |
Subject: |
[elpa] externals/phps-mode b94ee63396 089/212: More work on indentation |
Date: |
Wed, 26 Jan 2022 01:50:58 -0500 (EST) |
branch: externals/phps-mode
commit b94ee633961ebc3ad790524006804621a4d57be2
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
More work on indentation
---
phps-mode-indent.el | 53 +++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 39 insertions(+), 14 deletions(-)
diff --git a/phps-mode-indent.el b/phps-mode-indent.el
index d5baa6d4f9..3dd1927e12 100644
--- a/phps-mode-indent.el
+++ b/phps-mode-indent.el
@@ -83,18 +83,47 @@
(line-starts-with-closing-bracket
(phps-mode-indent--string-starts-with-closing-bracket-p line-string))
(line-starts-with-opening-doc-comment
(phps-mode-indent--string-starts-with-opening-doc-comment-p line-string))
(line-ends-with-assignment
(phps-mode-indent--string-ends-with-assignment-p line-string))
- (line-ends-with-opening-bracket
(phps-mode-indent--string-ends-with-opening-bracket-p line-string))
+ (line-ends-with-opening-bracket
(phps-mode-indent--string-ends-with-opening-bracket line-string))
(line-ends-with-terminus
(phps-mode-indent--string-ends-with-terminus-p line-string))
- (bracket-level (phps-mode-indent--get-string-brackets-count
line-string))
- (line-ends-with-implements-p (string-match-p "[\t
]+implements$" line-string)))
+ (bracket-level (phps-mode-indent--get-string-brackets-count
line-string)))
(message "Previous non-empty line: %S with indentation: %S"
line-string old-indentation)
(setq new-indentation old-indentation)
(goto-char point)
- (when line-ends-with-implements-p
+ ;; class MyClass implements
+ ;; myInterface
+ ;; or
+ ;; class MyClass extends
+ ;; myParent
+ (when (string-match-p "[\t ]+\\(extends\\|implements\\)$"
line-string)
(setq bracket-level (+ tab-width)))
+ ;; class MyClass
+ ;; implements myInterface
+ ;; or
+ ;; class MyClass
+ ;; extends myParent
+ ;; or
+ ;; class MyClass
+ ;; extends myParent
+ ;; implements MyInterface
+ (when
+ (string-match "^[\t ]*\\(extends\\|implements\\)"
current-line-string)
+ ;; TODO Should backtrack to class statement and increase
indentation from that
+ )
+
+ ;; class MyClass implements
+ ;; myInterface,
+ ;; myInterface2
+ ;; {
+ (when (and
+ current-line-starts-with-opening-bracket
+ (string= current-line-starts-with-opening-bracket "{")
+ (phps-mode-indent--backwards-looking-at-p
+ "[\t ]*implements[\n\t ]+\\([\n\t
]*[a-zA-Z_0-9]+,?\\)+[\n\t ]*{$"))
+ (setq new-indentation (- new-indentation tab-width)))
+
(when (> bracket-level 0)
(if (< bracket-level tab-width)
(setq new-indentation (+ new-indentation 1))
@@ -107,13 +136,6 @@
line-starts-with-closing-bracket)
(setq new-indentation (+ new-indentation tab-width)))
- (when (and
- current-line-starts-with-opening-bracket
- (string= current-line-starts-with-opening-bracket "{")
- (phps-mode-indent--backwards-looking-at-p
- "[\t ]*implements[\n\t ]+\\([\n\t
]*[a-zA-Z_0-9]+,?\\)+[\n\t ]*{$"))
- (setq new-indentation (- new-indentation tab-width)))
-
(when current-line-starts-with-closing-bracket
(setq new-indentation (- new-indentation tab-width)))
@@ -242,9 +264,12 @@
(match-string 0 string)
nil))
-(defun phps-mode-indent--string-ends-with-opening-bracket-p (string)
- "Get bracket count for STRING."
- (string-match-p "\\([\[{(]\\|<[a-zA-Z]+\\|[\t ]+implements\\)[\t ]*$"
string))
+(defun phps-mode-indent--string-ends-with-opening-bracket (string)
+ "If STRING end with opening bracket, return it, otherwise nil."
+ (if
+ (string-match "\\([\[{(]\\)[\t ]*$" string)
+ (match-string 0 string)
+ nil))
(defun phps-mode-indent--string-ends-with-assignment-p (string)
"Get bracket count for STRING."
- [elpa] externals/phps-mode 52b5692d91 017/212: Passed second test for bookkeeping via parser SDT, (continued)
- [elpa] externals/phps-mode 52b5692d91 017/212: Passed second test for bookkeeping via parser SDT, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 8115521ef8 011/212: Imenu-generation via parser SDT passing more tests, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 040b2564b0 031/212: Some work on AST bookkeeping, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 16c15c9ef4 004/212: Added type check to imenu-index generation, Christian Johansson, 2022/01/26
- [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 <=
- [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, 2022/01/26
- [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