@@ -102,85 +102,90 @@ STRING
102
102
If the string is an actual directory path, it is set as the absolute path
103
103
of the root directory, not the marker." )
104
104
(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))))
106
106
107
- ;;;### autoload
108
- (progn
109
107
(defvar-local php-project-bootstrap-scripts nil
110
108
" List of path to bootstrap php script file.
111
109
112
110
The ideal bootstrap file is silent, it only includes dependent files,
113
111
defines 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 )
115
113
116
- ;;;### autoload
117
- (progn
118
114
(defvar-local php-project-php-executable nil
119
115
" Path to php executable file." )
120
116
(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))))
122
118
123
- ;;;### autoload
124
- (progn
125
119
(defvar-local php-project-phan-executable nil
126
120
" 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 )
128
122
129
- ;;;### autoload
130
- (progn
131
123
(defvar-local php-project-coding-style nil
132
124
" Symbol value of the coding style of the project that PHP major mode refers to.
133
125
134
126
Typically 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 )
136
128
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
140
147
" Function name or path to REPL (interactive shell) script." )
141
- (make-variable-buffer-local 'php-project-repl )
142
148
(put 'php-project-repl 'safe-local-variable
143
149
#' (lambda (v ) (or (functionp v)
144
- (php-project--eval-bootstrap-scripts v)))))
150
+ (php-project--eval-bootstrap-scripts v))))
145
151
146
- ;;;### autoload
147
- (progn
148
- (defvar php-project-unit-test nil
152
+ (defvar-local php-project-unit-test nil
149
153
" Function name or path to unit test script." )
150
- (make-variable-buffer-local 'php-project-unit-test )
151
154
(put 'php-project-unit-test 'safe-local-variable
152
155
#' (lambda (v ) (or (functionp v)
153
- (php-project--eval-bootstrap-scripts v)))))
156
+ (php-project--eval-bootstrap-scripts v))))
154
157
155
- ;;;### autoload
156
- (progn
157
- (defvar php-project-deploy nil
158
+ (defvar-local php-project-deploy nil
158
159
" Function name or path to deploy script." )
159
- (make-variable-buffer-local 'php-project-deploy )
160
160
(put 'php-project-deploy 'safe-local-variable
161
161
#' (lambda (v ) (or (functionp v)
162
- (php-project--eval-bootstrap-scripts v)))))
162
+ (php-project--eval-bootstrap-scripts v))))
163
163
164
- ;;;### autoload
165
- (progn
166
- (defvar php-project-build nil
164
+ (defvar-local php-project-build nil
167
165
" Function name or path to build script." )
168
- (make-variable-buffer-local 'php-project-build )
169
166
(put 'php-project-build 'safe-local-variable
170
167
#' (lambda (v ) (or (functionp v)
171
- (php-project--eval-bootstrap-scripts v)))))
168
+ (php-project--eval-bootstrap-scripts v))))
172
169
173
- ;;;### autoload
174
- (progn
175
- (defvar php-project-server-start nil
170
+ (defvar-local php-project-server-start nil
176
171
" Function name or path to server-start script." )
177
- (make-variable-buffer-local 'php-project-server-start )
178
172
(put 'php-project-server-start 'safe-local-variable
179
173
#' (lambda (v ) (or (functionp v)
180
174
(php-project--eval-bootstrap-scripts v)))))
181
175
182
176
183
177
; ; 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 )))
184
189
185
190
(defun php-project--eval-bootstrap-scripts (val )
186
191
" 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'.")
213
218
(cons 'root " vendor/bin/phan" ))))
214
219
(executable-find " phan" )))
215
220
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
+
216
232
;;;### autoload
217
233
(defun php-project-get-bootstrap-scripts ()
218
234
" Return list of bootstrap script."
0 commit comments