[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode c9f715a1fd 093/212: Improved comments
From: |
Christian Johansson |
Subject: |
[elpa] externals/phps-mode c9f715a1fd 093/212: Improved comments |
Date: |
Wed, 26 Jan 2022 01:51:01 -0500 (EST) |
branch: externals/phps-mode
commit c9f715a1fda0efe3d24b7b28c06a6b4e5f56078a
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
Improved comments
---
phps-mode-indent.el | 50 +++++++++++++++++++++++++++++++------------
test/phps-mode-test-indent.el | 14 ++++++------
2 files changed, 43 insertions(+), 21 deletions(-)
diff --git a/phps-mode-indent.el b/phps-mode-indent.el
index 10579b8ad9..f0a5da08fb 100644
--- a/phps-mode-indent.el
+++ b/phps-mode-indent.el
@@ -132,7 +132,7 @@
;; (message "\nCurrent line: %S" current-line-string)
- ;; Try to find previous non-empty line
+ ;; TODO Try to find previous 2 non-empty lines
(while (and
(= (forward-line -1) 0)
line-is-empty-p)
@@ -151,16 +151,28 @@
(if line-is-empty-p
(indent-line-to 0)
- (let* ((old-indentation (phps-mode-indent--string-indentation
line-string))
- (current-line-starts-with-closing-bracket
(phps-mode-indent--string-starts-with-closing-bracket current-line-string))
- (current-line-starts-with-opening-bracket
(phps-mode-indent--string-starts-with-opening-bracket current-line-string))
- (line-starts-with-closing-bracket
(phps-mode-indent--string-starts-with-closing-bracket line-string))
- (line-ends-with-closing-bracket
(phps-mode-indent--string-ends-with-closing-bracket line-string))
- (line-starts-with-opening-doc-comment
(phps-mode-indent--string-starts-with-opening-doc-comment line-string))
- (line-ends-with-assignment
(phps-mode-indent--string-ends-with-assignment 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 line-string))
- (bracket-level (phps-mode-indent--get-string-brackets-count
line-string)))
+ (let* ((old-indentation
+ (phps-mode-indent--string-indentation line-string))
+ (current-line-starts-with-closing-bracket
+ (phps-mode-indent--string-starts-with-closing-bracket
current-line-string))
+ (current-line-starts-with-opening-bracket
+ (phps-mode-indent--string-starts-with-opening-bracket
current-line-string))
+ (current-line-ends-with-terminus
+ (phps-mode-indent--string-ends-with-terminus
current-line-string))
+ (line-starts-with-closing-bracket
+ (phps-mode-indent--string-starts-with-closing-bracket
line-string))
+ (line-ends-with-closing-bracket
+ (phps-mode-indent--string-ends-with-closing-bracket
line-string))
+ (line-starts-with-opening-doc-comment
+ (phps-mode-indent--string-starts-with-opening-doc-comment
line-string))
+ (line-ends-with-assignment
+ (phps-mode-indent--string-ends-with-assignment
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 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)
;; (message "line-ends-with-terminus: %S"
line-ends-with-terminus)
@@ -211,11 +223,13 @@
(string= line-ends-with-closing-bracket ")")
(string-match-p "^[\t ]*\\(if\\|while\\)[\t ]*("
line-string))
(setq new-indentation (+ new-indentation tab-width)))
-
;; else
;; echo 'Something';
- ;; TODO
+ (when (phps-mode-indent--string-starts-with-regexp
+ line-string
+ "else[\t ]*$")
+ (setq new-indentation (+ new-indentation tab-width)))
;; if (true)
;; echo 'Something';
@@ -223,9 +237,17 @@
(when (and
line-ends-with-terminus
(string= line-ends-with-terminus ";"))
- (when (phps-mode-indent--string-starts-with-regexp
current-line-string "[\t ]*else")
+ (when (phps-mode-indent--string-starts-with-regexp
+ current-line-string "[\t ]*else")
(setq new-indentation (- new-indentation tab-width))))
+ ;; if (true)
+ ;; echo 'Something';
+ ;; else
+ ;; echo 'Something else';
+ ;; echo true;
+ ;; TODO
+
(when (> bracket-level 0)
(if (< bracket-level tab-width)
(setq new-indentation (+ new-indentation 1))
diff --git a/test/phps-mode-test-indent.el b/test/phps-mode-test-indent.el
index f7ac40e08a..6185d49ec2 100644
--- a/test/phps-mode-test-indent.el
+++ b/test/phps-mode-test-indent.el
@@ -32,7 +32,7 @@
(message "Initial buffer:\n%S" string)
(phps-mode-test-indent--indent-whole-buffer)
(let ((buffer-contents (buffer-substring-no-properties (point-min)
(point-max))))
- (message "Indented buffer:\n%S" buffer-contents)
+ (message "\nIndented buffer:\n%S" buffer-contents)
(should (equal
buffer-contents
string)))))
@@ -349,8 +349,8 @@
)
-(defun phps-mode-test-indent--get-lines-indent-inline-if ()
- "Test for inline if indentations."
+(defun phps-mode-test-indent--get-lines-indent-inline-control-structures ()
+ "Test for inline control structures."
(phps-mode-test-indent--should-equal
"<?php\nif (true)\n echo 'Something';\nelse\n echo 'Something
else';\necho true;\n"
@@ -366,8 +366,8 @@
)
-(defun phps-mode-test-indent--get-lines-indent-alternative-if ()
- "Test for alternative if indentations."
+(defun phps-mode-test-indent--get-lines-indent-alternative-control-structures
()
+ "Test for alternative control structures."
(phps-mode-test-indent--should-equal
"<?php\nif (true):\n echo 'Something';\nelseif (true):\n echo
'Something';\nelse:\n echo 'Something else';\n echo 'Something else
again';\nendif;\necho true;\n"
@@ -829,8 +829,8 @@
(phps-mode-test-indent--helpers)
(phps-mode-test-indent--get-lines-indent-if)
(phps-mode-test-indent--get-lines-indent-classes)
- (phps-mode-test-indent--get-lines-indent-inline-if)
- (phps-mode-test-indent--get-lines-indent-alternative-if)
+ (phps-mode-test-indent--get-lines-indent-inline-control-structures)
+ (phps-mode-test-indent--get-lines-indent-alternative-control-structures)
(phps-mode-test-indent--get-lines-indent-multi-line-assignments)
(phps-mode-test-indent--get-lines-indent-switch-case)
(phps-mode-test-indent--get-lines-indent-psr-2)
- [elpa] externals/phps-mode 8b5ce22d87 072/212: Fixed issue with SDT for return statement, (continued)
- [elpa] externals/phps-mode 8b5ce22d87 072/212: Fixed issue with SDT for return statement, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 491c82a2a1 071/212: Added TODO item for bookkeeping via AST, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 5ec32f5f5a 076/212: Bookkeeping via AST passing all tests, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 228f212127 080/212: Starting on removing the old process tokens in string function, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 5b1f5b4774 079/212: Improved format of SDT, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 3f3a8bb0fa 081/212: Major refactor of indent tests, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode b469f0ffbb 088/212: Passing indentation for multi-line class implements, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode f69df4fdf6 083/212: Moved indentation to separate file and test, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 481deb6331 082/212: More work on indentation, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode fe9cb90c44 097/212: Passing indent test for some multi-line assignments, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode c9f715a1fd 093/212: Improved comments,
Christian Johansson <=
- [elpa] externals/phps-mode f0ab7a2cdb 095/212: Passed tests for inline control structures, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 08f57c1d36 107/212: Added TODO item for indent, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 3853ddf32a 099/212: Passed another concatenation test for indentation, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 1ed09d42f5 111/212: Passing another indent test, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode d205d8392f 113/212: Passed another indent test, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 1a62f48783 130/212: Improved indentation in cases with multi-expressions last line does not start with closing bracket, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode a3b9559880 121/212: Improved indent support for nested switch case, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode b4bf3caeb3 118/212: Added TODO note, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode b9956e278f 120/212: Indent support for closing bracket after closing multi-line assignment, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 4b4a821e6e 115/212: Started refactor of indent code, Christian Johansson, 2022/01/26