branch: externals/phps-mode commit d839f8aa113d523d50cd8fcc57b1519c283b5293 Author: Christian Johansson <christ...@cvj.se> Commit: Christian Johansson <christ...@cvj.se>
More work on indentation support --- phps-functions.el | 18 +++++++++++------- phps-test-lexer.el | 9 +++++---- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/phps-functions.el b/phps-functions.el index 9b8382a..e6bf6d3 100644 --- a/phps-functions.el +++ b/phps-functions.el @@ -38,14 +38,17 @@ (defun phps-mode/indent-line () "Indent line." - (let ((data (phps-mode/lexer-get-point-data))) - (if (nth 0 data) + (save-excursion + (beginning-of-line) + (let ((data (phps-mode/lexer-get-point-data))) + ;; Are we in scripting? + (if (nth 0 data) + (let ((indent-level (* (+ (nth 1 data) (nth 2 data)) 4))) + (message "inside scripting %s, indenting to column %s " data indent-level) + (indent-line-to indent-level)) (progn - (message "inside scripting %s" data) - (indent-line-to (nth 1 data))) - (progn - (message "Outside scripting %s" data) - (indent-relative))))) + (message "Outside scripting %s" data) + (indent-relative)))))) (defun phps-mode/indent-region () "Indent region." @@ -55,6 +58,7 @@ "PHP specific init-cleanup routines." (set (make-local-variable 'indent-line-function) #'phps-mode/indent-line) + (set (make-local-variable 'tab-width) 8) ;; (set (make-local-variable 'indent-line-function) #'phps-mode/indent-region) ) diff --git a/phps-test-lexer.el b/phps-test-lexer.el index d78df2b..5db8f02 100644 --- a/phps-test-lexer.el +++ b/phps-test-lexer.el @@ -141,7 +141,7 @@ (phps-mode/with-test-buffer "<?php //echo $contact_position;?><!--</div>-->" (should (equal phps-mode/lexer-tokens - '((T_OPEN_TAG 1 . 7) (T_COMMENT 7 . 32) (";" 32 . 34) (T_CLOSE_TAG 32 . 34)) + '((T_OPEN_TAG 1 . 7) (T_COMMENT 7 . 32) (";" 32 . 34) (T_CLOSE_TAG 32 . 34))))) (phps-mode/with-test-buffer @@ -284,9 +284,10 @@ (should (equal (list nil 0 0 0) (phps-mode/lexer-get-point-data)))) (phps-mode/with-test-buffer - "<html><head><title><?php if ($myCondition) { if ($mySeconCondition) { echo $title; } } ?></title><body>Bla bla</body></html>" - (goto-char 60) - (should (equal (list t 1 1 0) (phps-mode/lexer-get-point-data)))) + "<html><head><title><?php if ($myCondition) { if ($mySeconCondition) { echo $title; } } ?></title><body>Bla bla</body></html>" + ;; (message "Tokens: %s" phps-mode/lexer-tokens) + (goto-char 48) + (should (equal (list t 1 0 0) (phps-mode/lexer-get-point-data)))) (phps-mode/with-test-buffer "<html><head><title><?php if ($myCondition) { if ($mySeconCondition) { echo $title; } } ?></title><body>Bla bla</body></html>"