@@ -78,6 +78,17 @@ You can replace \"en\" with your ISO language code."
78
78
" Suffix for inserted namespace."
79
79
:group 'php
80
80
:type 'string )
81
+
82
+ (defcustom php-template-mode-alist
83
+ '((" \\ .blade" . web-mode)
84
+ (" \\ .phpt\\ '" . phpt-mode)
85
+ (" \\ .phtml\\ '" . web-mode))
86
+ " Automatically use another MAJOR-MODE when open template file."
87
+ :group 'php
88
+ :tag " PHP Template Mode Alist"
89
+ :type '(alist :key-type regexp :value-type function)
90
+ :link '(url-link :tag " web-mode" " http://web-mode.org/" )
91
+ :link '(url-link :tag " phpt-mode" " https://github.com/emacs-php/phpt-mode" ))
81
92
82
93
; ;; PHP Keywords
83
94
(defconst php-magical-constants
@@ -187,6 +198,19 @@ Look at the `php-executable' variable instead of the constant \"php\" command."
187
198
'flymake-php-init )))))
188
199
(list php-executable (cdr init))))
189
200
201
+ (eval-when-compile
202
+ (declare-function php-mode " php-mode" ))
203
+
204
+ ;;;### autoload
205
+ (defun php-mode-maybe ()
206
+ " Select PHP mode or other major mode."
207
+ (let ((mode (assoc-default buffer-file-name php-template-mode-alist #'string-match-p )))
208
+ (when (and mode (not (fboundp mode)))
209
+ (if (string-match-p " \\ .blade\\ ." buffer-file-name)
210
+ (warn " php-mode is NOT support blade template" )
211
+ (setq mode #'php-mode )))
212
+ (funcall (or mode #'php-mode ))))
213
+
190
214
;;;### autoload
191
215
(defun php-current-class ()
192
216
" Insert current class name if cursor in class context."
0 commit comments