Skip to content
Closed
Changes from all commits
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
22 changes: 20 additions & 2 deletions php-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)))

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)

Expand Down