branch: externals/phps-mode commit 897f249641ceaad14d8c5e2c89514055b8f21021 Author: Christian Johansson <christ...@cvj.se> Commit: Christian Johansson <christ...@cvj.se>
Work on alternative and inline indentation --- phps-mode-functions.el | 8 ++++++-- phps-mode-test-functions.el | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/phps-mode-functions.el b/phps-mode-functions.el index f77eb71..ab4e8f9 100644 --- a/phps-mode-functions.el +++ b/phps-mode-functions.el @@ -33,9 +33,10 @@ ;; NOTE Also format white-space inside the line, i.e. after function declarations? +;; TODO Add support for automatic parenthesis, bracket, square-bracket, single-quote and double-quote encapsulations + ;; TODO Support inline function indentations ;; TODO Support indentation for multi-line scalar assignments -;; TODO Add support for automatic parenthesis, bracket, square-bracket, single-quote and double-quote encapsulations (defun phps-mode-functions-indent-line () "Indent line." @@ -77,6 +78,7 @@ (first-token-is-closing-curly-bracket nil) (tokens phps-mode-lexer-tokens) (is-first-line-token t)) + ;; (message "token start %s, token end %s" start-token-number end-token-number) ;; (message "First token %s, last token %s" (car (nth start-token-number tokens)) (car (nth end-token-number tokens))) @@ -102,7 +104,9 @@ (setq is-first-line-token nil) ;; Is it a closing brace? - (when (string= token "}") + (when (or (string= token "}") + (eq token 'T_ELSE) + (eq token 'T_ELSEIF)) (setq first-token-is-closing-curly-bracket t))) (when (and valid-tokens diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el index af79b70..dfa39ed 100644 --- a/phps-mode-test-functions.el +++ b/phps-mode-test-functions.el @@ -164,12 +164,12 @@ (should (equal buffer-contents "<?php\n$var = [\n 'random' => [\n 'hello',\n ],\n];\n")))) (phps-mode-test-with-buffer - "<?php\nif (myRandomCondition()):\necho 'Something here';\n else:\n echo 'Something else here';\nendif;\n" - (goto-char 60) + "<?php\nif (myRandomCondition()):\necho 'Something here';\n else:\n echo 'Something else here 8';\nendif;\n" + (goto-char 62) (phps-mode-functions-indent-line) ;; (message "Tokens %s" phps-mode-lexer-tokens) (let ((buffer-contents (buffer-substring-no-properties (point-min) (point-max)))) - (should (equal buffer-contents "<?php\nif (myRandomCondition()):\necho 'Something here';\nelse:\n echo 'Something else here';\nendif;\n")))) + (should (equal buffer-contents "<?php\nif (myRandomCondition()):\necho 'Something here';\nelse:\n echo 'Something else here 8';\nendif;\n")))) ;; switch case