[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode 9c4a3ba 117/405: More work on alternative con
From: |
Stefan Monnier |
Subject: |
[elpa] externals/phps-mode 9c4a3ba 117/405: More work on alternative control structures |
Date: |
Sat, 13 Jul 2019 09:59:56 -0400 (EDT) |
branch: externals/phps-mode
commit 9c4a3ba7090536a3a03cc324a2a75ecadf681bf2
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>
More work on alternative control structures
---
phps-mode-functions.el | 43 +++++++++++++++++++++++++++++++------------
1 file changed, 31 insertions(+), 12 deletions(-)
diff --git a/phps-mode-functions.el b/phps-mode-functions.el
index 8999b45..930f7cb 100644
--- a/phps-mode-functions.el
+++ b/phps-mode-functions.el
@@ -198,6 +198,7 @@
;; TODO This function needs to keep track of alternative syntax for the
control structures: if, while, for, foreach, and switch
;; TODO This function needs to keep track of inline syntax for the control
structures: if, while, for, foreach, and switch
+;; TODO Support switch case as well
(defun phps-mode-functions-get-point-data ()
"Return information about point in tokens."
@@ -236,18 +237,7 @@
;; (message "Stopping iteration at: %s %s" start position)
(throw 'stop-iteration nil))
- ;; Does the token support inline and alternative syntax?
- (when (or
- (equal token 'T_IF)
- (equal token 'T_WHILE)
- (equal token 'T_FOR)
- (equal token 'T_FOREACH)
- (equal token 'T_SWITCH)
- (equal token 'T_ELSE)
- (equal token 'T_ELSEIF))
- (setq after-special-control-structure
start-round-bracket-level))
-
- ;; Did we find any token on this line?
+ ;; Did we find any token on current line?
(when (and (not found-line-tokens)
(>= token-start line-beginning)
(<= token-end line-end))
@@ -255,6 +245,8 @@
;; When end of token is equal or less to beginning of current
line
(when (<= token-end line-beginning)
+
+ ;; Change start token number
(when (null start-token-number)
(setq start-token-number -1))
(setq start-token-number (+ start-token-number 1))
@@ -314,6 +306,33 @@
(equal token 'T_ENDSWITCH))
(setq end-alternative-control-structure-level (-
end-alternative-control-structure-level 1))))
+ ;; Are we after a special control structure
+ ;; and does round bracket level match initial round bracket
level
+ ;; and is token not a round bracket
+ (when (and after-special-control-structure
+ (= after-special-control-structure
start-round-bracket-level)
+ (not (string= token ")"))
+ (not (string= token "(")))
+ (if (not (string= token "{"))
+ (progn
+ (message "After special control structure %s in buffer
%s" token (buffer-substring-no-properties (point-min) (point-max))))
+ ;; (message "Not after special control structure %s in
buffer %s" token (buffer-substring-no-properties (point-min) (point-max)))
+ )
+ (setq after-special-control-structure nil))
+
+ ;; Does the token support inline and alternative syntax?
+ (when (or
+ (equal token 'T_IF)
+ (equal token 'T_WHILE)
+ (equal token 'T_FOR)
+ (equal token 'T_FOREACH)
+ (equal token 'T_SWITCH)
+ (equal token 'T_ELSE)
+ (equal token 'T_ELSEIF))
+ ;; (message "Found special control structure %s %s" token
start-round-bracket-level)
+ (setq after-special-control-structure
start-round-bracket-level))
+
+
)))
(when (not found-line-tokens)
(setq start-token-number nil)
- [elpa] externals/phps-mode a899707 102/405: Updated comments, (continued)
- [elpa] externals/phps-mode a899707 102/405: Updated comments, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 89fac0b 094/405: Added another unit test for bracket less conditional, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 6ac718c 104/405: Removed non-breaking space from syntax table, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode a5beef1 097/405: Added support for square bracket indentation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 2c9746b 101/405: Added switch case unit test for lexer, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 47ad456 103/405: Fixed syntax table for white-spaces, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode cd1fdee 106/405: *** empty log message ***, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode efa297a 108/405: More work on renaming, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 529042e 109/405: More work on renaming, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 7688cd7 111/405: Got incremental lexer working after renaming again, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 9c4a3ba 117/405: More work on alternative control structures,
Stefan Monnier <=
- [elpa] externals/phps-mode 3272991 110/405: Merge branch 'master' of https://github.com/cjohansson/emacs-phps-mode, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 7c6ee3e 107/405: More work on renaming, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 46a8256 116/405: Starting implementation of tracking alternative control structure level, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 9ac21f1 120/405: More work on inline and alternative control structures, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 41ef691 112/405: Fixed lint warning of unused variables, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 12c22ee 119/405: More work on alternative and inline meta information, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 7e2e902 126/405: Fixed a unit test, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 80da137 114/405: Preparations for adding alternative and inline syntax, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode baab77a 121/405: Unit tests for inline control structures working, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode f0dc652 143/405: More work on new indentation function, Stefan Monnier, 2019/07/13