From ebf5b471c99120231713595b3e1a36e00f5b24a1 Mon Sep 17 00:00:00 2001 From: Joris Steyn Date: Sun, 5 Jun 2016 16:59:41 +0200 Subject: [PATCH] Retain the modification state on mode activation Since commit 86eab80 php-mode calls php-syntax-propertize-function on mode activation in emacs 25. This commit wraps the call in the with-silent-modifications macro so the modification state is retained, just like how emacs' syntax.el calls syntax-propertize functions. Resolves issue #307. --- php-mode-test.el | 7 +++++++ php-mode.el | 3 ++- tests/issue-307.php | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 tests/issue-307.php diff --git a/php-mode-test.el b/php-mode-test.el index 86826748..2f9a77f6 100644 --- a/php-mode-test.el +++ b/php-mode-test.el @@ -605,6 +605,13 @@ style from Drupal." (search-forward "$that") (should-not (eq 'font-lock-constant-face (get-text-property (- (point) 1) 'face))))) +(ert-deftest php-mode-test-issue-307 () + "Activating php-mode should not mark the buffer as modified." + (with-php-mode-test ("issue-307.php") + (set-buffer-modified-p nil) + (php-mode) + (should-not (buffer-modified-p)))) + ;;; php-mode-test.el ends here ;; Local Variables: diff --git a/php-mode.el b/php-mode.el index 9e33fdc7..9aae782c 100644 --- a/php-mode.el +++ b/php-mode.el @@ -1061,7 +1061,8 @@ PHP heredoc." php-beginning-of-defun-regexp) (when (>= emacs-major-version 25) - (php-syntax-propertize-function (point-min) (point-max)))) + (with-silent-modifications + (php-syntax-propertize-function (point-min) (point-max))))) ;; Define function name completion function diff --git a/tests/issue-307.php b/tests/issue-307.php new file mode 100644 index 00000000..ad844d33 --- /dev/null +++ b/tests/issue-307.php @@ -0,0 +1,3 @@ +