From 364b0ad5acd1f2d7d500e43e2c63f048f4e66439 Mon Sep 17 00:00:00 2001 From: Syohei YOSHIDA Date: Wed, 4 Mar 2015 10:39:15 +0900 Subject: [PATCH 1/3] Add unit test for #227 --- php-mode-test.el | 5 +++++ tests/issue-227.php | 12 ++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 tests/issue-227.php diff --git a/php-mode-test.el b/php-mode-test.el index c8bc1d3b..82872282 100644 --- a/php-mode-test.el +++ b/php-mode-test.el @@ -551,4 +551,9 @@ style from Drupal." (search-forward "return") (should (eq (current-indentation) (* 2 c-basic-offset))))) +(ert-deftest php-mode-test-issue-227 () + "multi-line strings indents " + (custom-set-variables '(php-lineup-cascaded-calls t)) + (with-php-mode-test ("issue-227.php" :indent t :style pear))) + ;;; php-mode-test.el ends here diff --git a/tests/issue-227.php b/tests/issue-227.php new file mode 100644 index 00000000..56a7d49e --- /dev/null +++ b/tests/issue-227.php @@ -0,0 +1,12 @@ + Date: Wed, 4 Mar 2015 10:39:57 +0900 Subject: [PATCH 2/3] Ignore '=' or '.' if it is inside string or comment --- php-mode.el | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/php-mode.el b/php-mode.el index bf7c9aab..d959e922 100644 --- a/php-mode.el +++ b/php-mode.el @@ -868,6 +868,15 @@ This is was done due to the problem reported here: "See `php-c-at-vsemi-p'." ) +(defsubst php-in-string-p () + (nth 3 (syntax-ppss))) + +(defsubst php-in-comment-p () + (nth 4 (syntax-ppss))) + +(defsubst php-in-string-or-comment-p () + (nth 8 (syntax-ppss))) + (defun php-lineup-string-cont (langelem) "Line up string toward equal sign or dot e.g. @@ -876,9 +885,12 @@ $str = 'some' this ^ lineup" (save-excursion (goto-char (cdr langelem)) - (when (or (search-forward "=" (line-end-position) t) - (search-forward "." (line-end-position) t)) - (vector (1- (current-column)))))) + (let (ret finish) + (while (and (not finish) (re-search-forward "[=.]" (line-end-position) t)) + (unless (php-in-string-or-comment-p) + (setq finish t + ret (vector (1- (current-column)))))) + ret))) (defun php-lineup-arglist-intro (langelem) (save-excursion @@ -911,12 +923,6 @@ the string HEREDOC-START." (string-match "\\w+" heredoc-start) (concat "^\\(" (match-string 0 heredoc-start) "\\)\\W")) -(defsubst php-in-string-p () - (nth 3 (syntax-ppss))) - -(defsubst php-in-comment-p () - (nth 4 (syntax-ppss))) - (defun php-syntax-propertize-function (start end) "Apply propertize rules from START to END." ;; (defconst php-syntax-propertize-function From 320eb00cdb410f5e2ec728aeae64befbda78f994 Mon Sep 17 00:00:00 2001 From: Syohei YOSHIDA Date: Wed, 4 Mar 2015 10:42:06 +0900 Subject: [PATCH 3/3] Update last modify date --- php-mode.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php-mode.el b/php-mode.el index d959e922..230840d0 100644 --- a/php-mode.el +++ b/php-mode.el @@ -11,7 +11,7 @@ (defconst php-mode-version-number "1.15.3" "PHP Mode version number.") -(defconst php-mode-modified "2015-02-16" +(defconst php-mode-modified "2015-03-04" "PHP Mode build date.") ;;; License