@@ -102,85 +102,90 @@ STRING
102102 If the string is an actual directory path, it is set as the absolute path
103103 of the root directory, not the marker." )
104104 (put 'php-project-root 'safe-local-variable
105- #' (lambda (v ) (or (stringp v) (assq v php-project-available-root-files)))))
105+ #' (lambda (v ) (or (stringp v) (assq v php-project-available-root-files))))
106106
107- ;;;### autoload
108- (progn
109107 (defvar-local php-project-bootstrap-scripts nil
110108 " List of path to bootstrap php script file.
111109
112110The ideal bootstrap file is silent, it only includes dependent files,
113111defines constants, and sets the class loaders." )
114- (put 'php-project-bootstrap-scripts 'safe-local-variable #'php-project--eval-bootstrap-scripts ))
112+ (put 'php-project-bootstrap-scripts 'safe-local-variable #'php-project--eval-bootstrap-scripts )
115113
116- ;;;### autoload
117- (progn
118114 (defvar-local php-project-php-executable nil
119115 " Path to php executable file." )
120116 (put 'php-project-php-executable 'safe-local-variable
121- #' (lambda (v ) (and (stringp v) (file-executable-p v)))))
117+ #' (lambda (v ) (and (stringp v) (file-executable-p v))))
122118
123- ;;;### autoload
124- (progn
125119 (defvar-local php-project-phan-executable nil
126120 " Path to phan executable file." )
127- (put 'php-project-phan-executable 'safe-local-variable #'php-project--eval-bootstrap-scripts ))
121+ (put 'php-project-phan-executable 'safe-local-variable #'php-project--eval-bootstrap-scripts )
128122
129- ;;;### autoload
130- (progn
131123 (defvar-local php-project-coding-style nil
132124 " Symbol value of the coding style of the project that PHP major mode refers to.
133125
134126Typically it is `pear' , `drupal' , `wordpress' , `symfony2' and `psr2' ." )
135- (put 'php-project-coding-style 'safe-local-variable #'symbolp ))
127+ (put 'php-project-coding-style 'safe-local-variable #'symbolp )
136128
137- ;;;### autoload
138- (progn
139- (defvar php-project-repl nil
129+ (defvar-local php-project-php-file-as-template 'auto
130+ "
131+ `auto' (default)
132+ Automatically switch to mode for template when HTML tag detected in file.
133+
134+ `t'
135+ Switch all PHP files in that directory to mode for HTML template.
136+
137+ `nil'
138+ Any .php in that directory is just a PHP script.
139+
140+ \(\( PATTERN . SYMBOL))
141+ Alist of file name pattern regular expressions and the above symbol pairs.
142+ PATTERN is regexp pattern.
143+ " )
144+ (put 'php-project-php-file-as-template 'safe-local-variable #'php-project--validate-php-file-as-template )
145+
146+ (defvar-local php-project-repl nil
140147 " Function name or path to REPL (interactive shell) script." )
141- (make-variable-buffer-local 'php-project-repl )
142148 (put 'php-project-repl 'safe-local-variable
143149 #' (lambda (v ) (or (functionp v)
144- (php-project--eval-bootstrap-scripts v)))))
150+ (php-project--eval-bootstrap-scripts v))))
145151
146- ;;;### autoload
147- (progn
148- (defvar php-project-unit-test nil
152+ (defvar-local php-project-unit-test nil
149153 " Function name or path to unit test script." )
150- (make-variable-buffer-local 'php-project-unit-test )
151154 (put 'php-project-unit-test 'safe-local-variable
152155 #' (lambda (v ) (or (functionp v)
153- (php-project--eval-bootstrap-scripts v)))))
156+ (php-project--eval-bootstrap-scripts v))))
154157
155- ;;;### autoload
156- (progn
157- (defvar php-project-deploy nil
158+ (defvar-local php-project-deploy nil
158159 " Function name or path to deploy script." )
159- (make-variable-buffer-local 'php-project-deploy )
160160 (put 'php-project-deploy 'safe-local-variable
161161 #' (lambda (v ) (or (functionp v)
162- (php-project--eval-bootstrap-scripts v)))))
162+ (php-project--eval-bootstrap-scripts v))))
163163
164- ;;;### autoload
165- (progn
166- (defvar php-project-build nil
164+ (defvar-local php-project-build nil
167165 " Function name or path to build script." )
168- (make-variable-buffer-local 'php-project-build )
169166 (put 'php-project-build 'safe-local-variable
170167 #' (lambda (v ) (or (functionp v)
171- (php-project--eval-bootstrap-scripts v)))))
168+ (php-project--eval-bootstrap-scripts v))))
172169
173- ;;;### autoload
174- (progn
175- (defvar php-project-server-start nil
170+ (defvar-local php-project-server-start nil
176171 " Function name or path to server-start script." )
177- (make-variable-buffer-local 'php-project-server-start )
178172 (put 'php-project-server-start 'safe-local-variable
179173 #' (lambda (v ) (or (functionp v)
180174 (php-project--eval-bootstrap-scripts v)))))
181175
182176
183177; ; Functions
178+ (defun php-project--validate-php-file-as-template (val )
179+ " Return T when `VAL' is valid list of safe ."
180+ (cond
181+ ((null val) t )
182+ ((memq val '(t auto)) t )
183+ ((listp val)
184+ (cl-loop for v in val
185+ always (and (consp v)
186+ (stringp (car v))
187+ (php-project--validate-php-file-as-template (cdr v)))))
188+ (t nil )))
184189
185190(defun php-project--eval-bootstrap-scripts (val )
186191 " Return T when `VAL' is valid list of safe bootstrap php script."
@@ -213,6 +218,17 @@ Typically it is `pear', `drupal', `wordpress', `symfony2' and `psr2'.")
213218 (cons 'root " vendor/bin/phan" ))))
214219 (executable-find " phan" )))
215220
221+ (defun php-project-get-file-html-template-type (filename )
222+ " Return symbol T, NIL or `auto' by `FILENAME' ."
223+ (cond
224+ ((not php-project-php-file-as-template) nil )
225+ ((eq t php-project-php-file-as-template) t )
226+ ((eq 'auto php-project-php-file-as-template) 'auto )
227+ ((listp php-project-php-file-as-template)
228+ (assoc-default filename php-project-php-file-as-template #'string-match-p ))
229+ (t (prog1 nil
230+ (warn " php-project-php-file-as-template is unexpected format" )))))
231+
216232;;;### autoload
217233(defun php-project-get-bootstrap-scripts ()
218234 " Return list of bootstrap script."
0 commit comments