From 8709c2760b8e3b156c577b8eaf2b04b741cc3525 Mon Sep 17 00:00:00 2001 From: Aaron Bieber Date: Fri, 12 Aug 2016 07:57:34 -0400 Subject: [PATCH 1/2] Fix #314; point is moved when php-mode starts --- php-mode.el | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/php-mode.el b/php-mode.el index 1b91bf06..c69a3cea 100644 --- a/php-mode.el +++ b/php-mode.el @@ -931,11 +931,12 @@ the string HEREDOC-START." (while (and (< (point) end) (re-search-forward php-heredoc-start-re end t)) (php-heredoc-syntax)) - (goto-char start) - (while (re-search-forward "['\"]" end t) - (when (php-in-comment-p) - (c-put-char-property (match-beginning 0) - 'syntax-table (string-to-syntax "_"))))) + (save-excursion + (goto-char start) + (while (re-search-forward "['\"]" end t) + (when (php-in-comment-p) + (c-put-char-property (match-beginning 0) + 'syntax-table (string-to-syntax "_")))))) (defun php-heredoc-syntax () "Mark the boundaries of searched heredoc." From 320828eb2189e120bbfef36e0f838096002b3a15 Mon Sep 17 00:00:00 2001 From: Aaron Bieber Date: Fri, 12 Aug 2016 07:58:55 -0400 Subject: [PATCH 2/2] Add test for #314 --- php-mode-test.el | 7 +++++++ tests/issue-314.php | 3 +++ 2 files changed, 10 insertions(+) create mode 100644 tests/issue-314.php diff --git a/php-mode-test.el b/php-mode-test.el index a2ac77b4..64b03c9f 100644 --- a/php-mode-test.el +++ b/php-mode-test.el @@ -612,6 +612,13 @@ style from Drupal." (php-mode) (should-not (buffer-modified-p)))) +(ert-deftest php-mode-test-issue-314 () + "Activating php-mode should not move point." + (with-php-mode-test ("issue-314.php") + (let ((orig-point (point))) + (php-mode) + (should (eq (point) orig-point))))) + (ert-deftest php-mode-test-issue-310 () "Proper indentation after function with return type." (with-php-mode-test ("issue-310.php" :indent t :magic t))) diff --git a/tests/issue-314.php b/tests/issue-314.php new file mode 100644 index 00000000..ad844d33 --- /dev/null +++ b/tests/issue-314.php @@ -0,0 +1,3 @@ +