diff --git a/php-mode.el b/php-mode.el index e1b2597b..c171ebfa 100644 --- a/php-mode.el +++ b/php-mode.el @@ -161,6 +161,15 @@ Turning this on will open it whenever `php-mode' is loaded." "Should detect presence of html tags." :type 'boolean) +(defcustom php-template-mode-alist + '(("\\.blade\\." . web-mode) + ;; ("\\.phtml\\'" . web-mode) + ;; ("\\.tpl\\." . web-mode) + ) + "Automatically use another MAJOR-MODE when open template file." + :type 'alist + :link '(url-link :tag "web-mode" "http://web-mode.org/")) + (defsubst php-in-string-p () (nth 3 (syntax-ppss))) @@ -1229,6 +1238,16 @@ After setting the stylevars run hooks according to STYLENAME (php-mode-debug--message "Thank you!") (pop-to-buffer (php-mode-debug--buffer 'top))) +;;;###autoload +(defun php-mode-maybe () + "Select PHP mode or other major mode." + (let ((mode (assoc-default buffer-file-name php-template-mode-alist #'string-match-p))) + (when (and mode (not (fboundp mode))) + (cond + ((string-match-p "\\.blade\\." buffer-file-name) + (warn "php-mode is NOT support blade template")))) + (funcall (or mode #'php-mode)))) + ;;;###autoload (define-derived-mode php-mode c-mode "PHP" "Major mode for editing PHP code. @@ -1855,8 +1874,7 @@ The output will appear in the buffer *PHP*." ".php_cs" ".php_cs.dist"))) string-end)) - 'php-mode) - t) + 'php-mode-maybe)) (provide 'php-mode)