[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode b2a5700 218/405: Fixed indentation for multi-
From: |
Stefan Monnier |
Subject: |
[elpa] externals/phps-mode b2a5700 218/405: Fixed indentation for multi-line optional function arguments |
Date: |
Sat, 13 Jul 2019 10:00:16 -0400 (EDT) |
branch: externals/phps-mode
commit b2a57002bd5212a0a99f98f5cd82629ac1d6aa1f
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>
Fixed indentation for multi-line optional function arguments
---
phps-mode-functions.el | 9 +++++++++
phps-mode-test-functions.el | 4 ++--
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/phps-mode-functions.el b/phps-mode-functions.el
index d5bd9da..57ae83d 100644
--- a/phps-mode-functions.el
+++ b/phps-mode-functions.el
@@ -86,6 +86,7 @@
(in-class-declaration nil)
(in-class-declaration-level 0)
(token nil)
+ (in-function-declaration nil)
(token-start-line-number 0)
(token-end-line-number)
(tokens (nreverse phps-mode-lexer-tokens))
@@ -166,6 +167,13 @@
(setq in-class-declaration-level 1)
(setq class-declaration-started-this-line t)))
+ ;; Keep track of function declarations
+ (if (and in-function-declaration
+ (string= token "{"))
+ (setq in-function-declaration nil)
+ (when (equal token 'T_FUNCTION)
+ (setq in-function-declaration t)))
+
;; Keep track of curly bracket level
(when (or (equal token 'T_CURLY_OPEN)
(equal token 'T_DOLLAR_OPEN_CURLY_BRACES)
@@ -318,6 +326,7 @@
;; (message "In assignment on new-line at %s" token)
))
(when (and (not after-special-control-structure)
+ (not in-function-declaration)
(string= token "="))
;; (message "Started assignment")
(setq in-assignment round-bracket-level)
diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el
index 7b4e183..e0f6ee7 100644
--- a/phps-mode-test-functions.el
+++ b/phps-mode-test-functions.el
@@ -232,8 +232,8 @@
(should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (1 0)) (5 (0 0)) (6 (0
0))) (phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
- "<?php\nclass MyClass\n{\n public function __construct(\n
$arg1,\n $arg2\n ) {\n echo 'here';\n }\n}"
- "Class multi-line function arguments"
+ "<?php\nclass MyClass\n{\n public function __construct(\n $arg1 =
false,\n $arg2 = []\n ) {\n echo 'here';\n }\n}"
+ "Class multi-line optional function arguments"
;; (message "Tokens: %s" phps-mode-lexer-tokens)
(should (equal '((1 (0 0)) (2 (0 0)) (3 (0 0)) (4 (1 0)) (5 (2 0)) (6 (2
0)) (7 (1 0)) (8 (2 0)) (9 (1 0)) (10 (0 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
- [elpa] externals/phps-mode 86404c8 207/405: New algorithm now passes tests for alternative control structure, (continued)
- [elpa] externals/phps-mode 86404c8 207/405: New algorithm now passes tests for alternative control structure, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 8b4c188 188/405: Now able to detect indent change of scope with same nesting level, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 91715f6 217/405: Added another test for multi-line function arguments, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 75c4af4 214/405: Fixed indentation for lines wrapped in scripting open/close, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode d754163 221/405: More work on multi-line token-less lines, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 8947e6e 202/405: Conceptual work on indentation-calculation for multi-line assignment, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode fc2e8b7 212/405: Added logic to indent token-less lines as well, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 8707777 237/405: Updated README, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 2d4646f 203/405: Work on inline control structure indentation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 202827b 198/405: New indentation algorithm now supports inline control structures, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode b2a5700 218/405: Fixed indentation for multi-line optional function arguments,
Stefan Monnier <=
- [elpa] externals/phps-mode f7186a1 239/405: Preparations for hierarchical imenu, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 43bf350 216/405: Added tests for token-less lines, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 0de10fa 235/405: Passes first test for imenu, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode f791cee 234/405: Started on unit tests for imenu-index generation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode b56a15c 233/405: Removed debugging output, updated todo items, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 73784d0 225/405: Cleaned up tests for indentation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode f7e7c74 219/405: Work on indentation for switch-case, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode c2af31e 240/405: Imenu support now shows hierarchical information, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 55953de 232/405: Lexer now doesn't find keywords in function names, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode b8e9449 247/405: Refactored Imenu to use a persistent variable per buffer, Stefan Monnier, 2019/07/13