Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply Stefan Monnier's patch (3) #740

Merged
merged 2 commits into from
Apr 10, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Use syntax-propertize-precompile-rules for php-syntax-propertize-func…
…tion
  • Loading branch information
monnier authored and zonuexe committed Apr 10, 2023
commit 4b03e9b956fa78a87b5707308eb0d92854111513
27 changes: 13 additions & 14 deletions lisp/php-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -995,20 +995,19 @@ HEREDOC-START."

(eval-and-compile
(defconst php-syntax-propertize-rules
`((php-heredoc-start-re
(0 (ignore (php--syntax-propertize-heredoc
(match-beginning 0)
(or (match-string 1) (match-string 2) (match-string 3))
(null (match-string 3))))))
(,(rx "#[")
(0 (ignore (php--syntax-propertize-attributes (match-beginning 0)))))
(,(rx (or "'" "\"" ))
(0 (ignore (php--syntax-propertize-quotes-in-comment (match-beginning 0)))))))

(defmacro php-build-propertize-function ()
`(byte-compile (syntax-propertize-rules ,@php-syntax-propertize-rules)))

(defalias 'php-syntax-propertize-function (php-build-propertize-function)))
(syntax-propertize-precompile-rules
(php-heredoc-start-re
(0 (ignore (php--syntax-propertize-heredoc
(match-beginning 0)
(or (match-string 1) (match-string 2) (match-string 3))
(null (match-string 3))))))
((rx "#[")
(0 (ignore (php--syntax-propertize-attributes (match-beginning 0)))))
((rx (or "'" "\""))
(0 (ignore (php--syntax-propertize-quotes-in-comment (match-beginning 0))))))))

(defalias 'php-syntax-propertize-function
(syntax-propertize-rules php-syntax-propertize-rules))

(defun php--syntax-propertize-heredoc (start id _is-heredoc)
"Apply propertize Heredoc and Nowdoc from START, with ID and IS-HEREDOC."
Expand Down