branch: externals/phps-mode commit 40ce934c11f3e9fc45686f1ad0e937abce62c0dc Author: Christian Johansson <christ...@cvj.se> Commit: Christian Johansson <christ...@cvj.se>
Indent support for string-doc in assignment --- phps-mode-indent.el | 62 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 54 insertions(+), 8 deletions(-) diff --git a/phps-mode-indent.el b/phps-mode-indent.el index 9d48448496..2a39eb9df4 100644 --- a/phps-mode-indent.el +++ b/phps-mode-indent.el @@ -222,7 +222,7 @@ (previous-line-starts-with-opening-doc-comment (phps-mode-indent--string-starts-with-opening-doc-comment previous-line-string)) - (previous-line-starts-with-closing-doc-comment + (previous-line-ends-with-closing-doc-comment (phps-mode-indent--string-ends-with-closing-doc-comment previous-line-string)) (previous-line-ends-with-assignment @@ -735,6 +735,11 @@ ;; 'here' ;; ); ;; echo 'here'; + ;; or + ;; $var = <<<EOD + ;; OKASDOKASD + ;; EOD; + ;; echo 'here'; ((and previous-line-ends-with-terminus (string= previous-line-ends-with-terminus ";") @@ -752,18 +757,30 @@ (let ((not-found t) (is-assignment nil) + (is-string-doc) (parenthesis-level 0) (is-bracket-less-command nil) (is-same-line-p t)) - (while (and - not-found - (search-backward-regexp "\\(;\\|{\\|(\\|)\\|=\\|echo[\t ]+\\|print[\t ]+\\|\n\\)" nil t)) - (let ((match - (buffer-substring-no-properties - (match-beginning 0) (match-end 0)))) + (while + (and + not-found + (search-backward-regexp + "\\(;\\|{\\|(\\|)\\|=\\|echo[\t ]+\\|print[\t ]+\\|\n\\|<<<'?\"?[a-zA-Z0-9]+'?\"?\\)" + nil + t)) + (let ((match (match-string-no-properties 0))) (cond ((string= match "\n") (setq is-same-line-p nil)) + ((string-match-p + "<<<'?\"?[a-zA-Z0-9]+'?\"?" + match) + (setq + is-string-doc + t) + (setq + not-found + nil)) (t (when (string= match ")") (setq parenthesis-level (1- parenthesis-level))) @@ -780,6 +797,18 @@ parenthesis-level (1+ parenthesis-level))))))) + ;; $var = <<<EOD + ;; OKASDOKASD + ;; EOD; + ;; echo 'here'; + (when is-string-doc + (setq + new-indentation + (phps-mode-indent--string-indentation + (buffer-substring-no-properties + (line-beginning-position) + (line-end-position))))) + ;; echo 'there' . ;; 'here'; ;; echo 'here'; @@ -868,6 +897,12 @@ ;; array( ;; 'hello' ;; ) + ;; but ignore + ;; [ + ;; ] + ;; or + ;; array( + ;; ) ((and current-line-starts-with-closing-bracket (not previous-line-ends-with-opening-bracket)) @@ -875,13 +910,19 @@ new-indentation (- new-indentation tab-width))) + ;; /** + ;; * here + ;; but ignore + ;; /** */ + ;; here ((and previous-line-starts-with-opening-doc-comment - (not previous-line-starts-with-closing-doc-comment)) + (not previous-line-ends-with-closing-doc-comment)) (setq new-indentation (+ new-indentation 1))) + ;; $var = ((and previous-line-ends-with-assignment (<= previous-bracket-level 0)) @@ -889,6 +930,11 @@ new-indentation (+ new-indentation tab-width))) + ;; )) { + ;; echo 'here'; + ;; or + ;; ]][ + ;; 25 ((and previous-line-ends-with-opening-bracket (< previous-bracket-level 0))