From 03e99851162ca37fb42678c8d423fbdd4d0a400e Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Mon, 2 Aug 2021 01:26:53 +0900 Subject: [PATCH 1/3] Refactor regexp --- lisp/php.el | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lisp/php.el b/lisp/php.el index ffb6cfbf..28fa97f5 100644 --- a/lisp/php.el +++ b/lisp/php.el @@ -223,7 +223,17 @@ it is the character that will terminate the string, or t if the string should be (bound-and-true-p poly-php-html-mode)) (defconst php-beginning-of-defun-regexp - "^\\s-*\\(?:\\(?:abstract\\|final\\|private\\|protected\\|public\\|static\\)\\s-+\\)*function\\s-+&?\\(\\(\\sw\\|\\s_\\)+\\)\\s-*(" + (eval-when-compile + (rx bol + (* (syntax whitespace)) + (* (or "abstract" "final" "private" "protected" "public" "static") + (+ (syntax whitespace))) + "function" + (+ (syntax whitespace)) + (? "&" (* (syntax whitespace))) + (group (+ (or (syntax word) (syntax symbol)))) + (* (syntax whitespace)) + "(")) "Regular expression for a PHP function.") (eval-when-compile From bd3bd230e70e897f841b9cd97eb4d19890e93b94 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Mon, 2 Aug 2021 01:58:06 +0900 Subject: [PATCH 2/3] Fix syntax testing method --- tests/php-mode-test.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/php-mode-test.el b/tests/php-mode-test.el index f31b8daa..9c647f78 100644 --- a/tests/php-mode-test.el +++ b/tests/php-mode-test.el @@ -348,12 +348,12 @@ style from Drupal." (with-php-mode-test ("issue-124.php" :indent t) (search-forward "Start of heredoc") ;; The heredoc should be recognized as a string. - (dolist (syntax (c-guess-basic-syntax)) - (should (eq (car syntax) 'string))) + (should (equal (mapcar #'car (c-guess-basic-syntax)) + '(statement-cont))) (search-forward "function bar") ;; After the heredoc should *not* be recognized as a string. - (dolist (syntax (c-guess-basic-syntax)) - (should (not (eq (car syntax) 'string)))))) + (should (equal (mapcar #'car (c-guess-basic-syntax)) + '(topmost-intro-cont))))) (ert-deftest php-mode-test-issue-136 () "Proper highlighting for variable interpolation." From b3a044577a4a15cfe02a08e82c167b578ec5a8cb Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Mon, 2 Aug 2021 03:17:42 +0900 Subject: [PATCH 3/3] Revert "Fix syntax testing method" This reverts commit bd3bd230e70e897f841b9cd97eb4d19890e93b94. --- tests/php-mode-test.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/php-mode-test.el b/tests/php-mode-test.el index 9c647f78..f31b8daa 100644 --- a/tests/php-mode-test.el +++ b/tests/php-mode-test.el @@ -348,12 +348,12 @@ style from Drupal." (with-php-mode-test ("issue-124.php" :indent t) (search-forward "Start of heredoc") ;; The heredoc should be recognized as a string. - (should (equal (mapcar #'car (c-guess-basic-syntax)) - '(statement-cont))) + (dolist (syntax (c-guess-basic-syntax)) + (should (eq (car syntax) 'string))) (search-forward "function bar") ;; After the heredoc should *not* be recognized as a string. - (should (equal (mapcar #'car (c-guess-basic-syntax)) - '(topmost-intro-cont))))) + (dolist (syntax (c-guess-basic-syntax)) + (should (not (eq (car syntax) 'string)))))) (ert-deftest php-mode-test-issue-136 () "Proper highlighting for variable interpolation."