branch: externals/phps-mode commit f2520450c825dabe03a402d9403ad8f72202fe4d Author: Christian Johansson <christ...@cvj.se> Commit: Christian Johansson <christ...@cvj.se>
Indentation improved for multi-line chained object method calls --- TODO.md | 16 ---------------- phps-mode-indent.el | 6 ------ phps-mode-macros.el | 6 +++--- test/phps-mode-test-indent.el | 1 - 4 files changed, 3 insertions(+), 26 deletions(-) diff --git a/TODO.md b/TODO.md index 492c21b31a..673893788f 100644 --- a/TODO.md +++ b/TODO.md @@ -2,22 +2,6 @@ ## Indentation -* Lines after comment looking like an assignment like: - -$var = 23; // 23 = Company -echo 'was here'; - -or - -$var = 23; /* 23 = Company */ -echo 'was here'; - -* Multi-lined chained object - -$var = Object->myMethod() - ->myMethod2(); -echo 'here'; - ## Code intelligence * Bookkeeping of chained object operators like WC()->cart->subtotal diff --git a/phps-mode-indent.el b/phps-mode-indent.el index 0977a1a38f..f7becc516d 100644 --- a/phps-mode-indent.el +++ b/phps-mode-indent.el @@ -885,7 +885,6 @@ new-indentation tab-width))) - ;; TODO Add :: as well ;; LINE CONTINUING CHAINING OBJECT OPERATORS ;; $myObject->myFunction() ;; ->myFunction2() @@ -905,7 +904,6 @@ 'line-continuing-object-operators) (let ((not-found t) (started-chaining-on-this-line t) - (is-assignment) (is-string-concatenation) (is-bracket-less-command) (is-same-line-p t)) @@ -961,9 +959,6 @@ ((string= "=" match) - (setq - is-assignment - t) (setq not-found nil)) @@ -981,7 +976,6 @@ ))) (when (and - (not is-assignment) (not is-string-concatenation) (not started-chaining-on-this-line) (not is-bracket-less-command)) diff --git a/phps-mode-macros.el b/phps-mode-macros.el index c3cffb5e82..bad8a8a2ca 100644 --- a/phps-mode-macros.el +++ b/phps-mode-macros.el @@ -12,10 +12,10 @@ nil "Debug messages during macro expansion time, default nil.") -(defmacro phps-mode-debug-message (&rest message) - "Display debug MESSAGE when debug flag is on." +(defmacro phps-mode-debug-message (&rest code) + "Run CODE only when debug flag is on." `(when ,phps-mode-macrotime-debug - ,@message)) + ,@code)) (provide 'phps-mode-macros) ;;; phps-mode-macros.el ends here diff --git a/test/phps-mode-test-indent.el b/test/phps-mode-test-indent.el index 4152c9d414..3a1c40b5b7 100644 --- a/test/phps-mode-test-indent.el +++ b/test/phps-mode-test-indent.el @@ -668,7 +668,6 @@ "<?php\n$var = 23; // 23 = Company\necho 'was here';" "Line after line that have an assignment commented out") - ;; TODO Make this pass (phps-mode-test-indent--should-equal "<?php\n$var = Object->myMethod()\n ->myMethod2();\necho 'here';" "Line after assignment were an chaining of object methods started")