[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode e5df43eea9 187/212: More tweaking of indentat
From: |
Christian Johansson |
Subject: |
[elpa] externals/phps-mode e5df43eea9 187/212: More tweaking of indentation helpers |
Date: |
Wed, 26 Jan 2022 01:51:25 -0500 (EST) |
branch: externals/phps-mode
commit e5df43eea9ec95821ac0e116db80ddcf52f04600
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
More tweaking of indentation helpers
---
phps-mode-indent.el | 63 +++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 47 insertions(+), 16 deletions(-)
diff --git a/phps-mode-indent.el b/phps-mode-indent.el
index 8164ae8a01..1210770b49 100644
--- a/phps-mode-indent.el
+++ b/phps-mode-indent.el
@@ -259,8 +259,9 @@
(if from-end-of-line
(end-of-line)
(beginning-of-line)
- (when (search-forward-regexp "[^])}\t ]")
- (forward-char -1)))
+ (if (search-forward-regexp "[^])}\t ]" nil t)
+ (forward-char -1)
+ (end-of-line)))
(let ((not-found-bracket-start t)
(parenthesis-level 0))
(while
@@ -307,7 +308,6 @@
(old-point (point))
(reference-line)
(found-semi-colon))
- (search-backward-regexp ";" nil t) ;; Skip previous semi-colon
(while
(and
@@ -336,23 +336,54 @@
not-found
nil))
+ ;; Alternative control structures are always
+ ;; indication of start of command
+ ((string-match-p
+ "\\:[\t ]*$"
+ match)
+ (setq
+ not-found
+ nil)
+ (setq
+ reference-line
+ (buffer-substring-no-properties
+ (line-beginning-position)
+ (line-end-position))))
+
;; A second semi-colon is always a indicator of
;; a end of a previous command
+ ;; Some keywords always indicate a start of command
((string-match-p
- "\\(;\\|:\\)[\t ]*$"
+ "\\;[\t ]*$"
match)
- (if found-semi-colon
- (setq
- not-found
- nil)
- (setq
- reference-line
- (buffer-substring-no-properties
- (line-beginning-position)
- (line-end-position)))
- (setq
- found-semi-colon
- t)))
+ (let ((is-statement
+ (string-match-p
+ "^[\t
]*\\(endswitch\\|endforeach\\|endwhile\\|exit\\|die\\|echo[\t ]+.*\\)[\t ]*;$"
+ (buffer-substring-no-properties
+ (line-beginning-position)
+ (line-end-position)))))
+ (if is-statement
+ (progn
+ (setq
+ not-found
+ nil)
+ (setq
+ reference-line
+ (buffer-substring-no-properties
+ (line-beginning-position)
+ (line-end-position))))
+ (if found-semi-colon
+ (setq
+ not-found
+ nil)
+ (setq
+ reference-line
+ (buffer-substring-no-properties
+ (line-beginning-position)
+ (line-end-position)))
+ (setq
+ found-semi-colon
+ t)))))
(t
(setq
- [elpa] externals/phps-mode 3a594466d5 100/212: Passed indent test for multi-line assignments, (continued)
- [elpa] externals/phps-mode 3a594466d5 100/212: Passed indent test for multi-line assignments, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 7deebc5f79 101/212: Improved indent test descriptions, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode d5d80017bc 104/212: Passed indent tests for concatenated string, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode e083e90ac0 108/212: Passing more indentation tests for PSR-2, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 84d447e4e6 119/212: Added TODO item, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 1ab6ac7324 131/212: Added failing tests for indentation, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 7135a30446 173/212: Updated TODO items, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 63c5fef240 175/212: Started on tests for more basic functions of indentation, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 735f1e0c89 176/212: More notes, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 73d460d5a4 181/212: Passing lexer tests with optimized lexer, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode e5df43eea9 187/212: More tweaking of indentation helpers,
Christian Johansson <=
- [elpa] externals/phps-mode 413547fbf1 188/212: Searching for previous bracket now steps over optional PHP starting tags, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 4b4a96fda2 208/212: Improved cache filename, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode ef97058a67 184/212: Added more tests for indentation helper functions, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode a1af5b11fb 040/212: More work on bookkeeping of class properties via AST, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 4dc07c9041 050/212: Bookkeeping via AST working with assigned variables from array, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 4d226f18cc 048/212: Bookkeeping via AST working with referenced foreach variables, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 5603e6266b 047/212: SDT for array values, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 787d82313e 045/212: Bookkeeping via AST now tracks variables around inline-functions, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode a629baba89 053/212: More work on bookkeeping via AST for arrow function variables, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode df0b707a61 044/212: Added parser SDT for inline-function, Christian Johansson, 2022/01/26