|
72 | 72 | ;; Constants |
73 | 73 | (defconst php-project-composer-autoloader "vendor/autoload.php") |
74 | 74 |
|
| 75 | +;; Custom variables |
| 76 | +(defgroup php-project nil |
| 77 | + "Major mode for editing PHP code." |
| 78 | + :tag "PHP Project" |
| 79 | + :prefix "php-project-" |
| 80 | + :group 'php) |
| 81 | + |
| 82 | +(defcustom php-project-auto-detect-etags-file nil |
| 83 | + "If `T', automatically detect etags file when file is opened." |
| 84 | + :tag "PHP Project Auto Detect Etags File" |
| 85 | + :group 'php-project |
| 86 | + :type 'boolean) |
| 87 | + |
75 | 88 | ;; Variables |
76 | 89 | (defvar php-project-available-root-files |
77 | 90 | '((projectile ".projectile") |
@@ -104,6 +117,12 @@ STRING |
104 | 117 | (put 'php-project-root 'safe-local-variable |
105 | 118 | #'(lambda (v) (or (stringp v) (assq v php-project-available-root-files)))) |
106 | 119 |
|
| 120 | + (defvar-local php-project-etags-file nil) |
| 121 | + (put 'php-project-etags-file 'safe-local-variable |
| 122 | + #'(lambda (v) (or (functionp v) |
| 123 | + (eq v t) |
| 124 | + (php-project--eval-bootstrap-scripts v)))) |
| 125 | + |
107 | 126 | (defvar-local php-project-bootstrap-scripts nil |
108 | 127 | "List of path to bootstrap php script file. |
109 | 128 |
|
@@ -172,7 +191,6 @@ Typically it is `pear', `drupal', `wordpress', `symfony2' and `psr2'.") |
172 | 191 | (put 'php-project-server-start 'safe-local-variable |
173 | 192 | #'(lambda (v) (or (functionp v) |
174 | 193 | (php-project--eval-bootstrap-scripts v))))) |
175 | | - |
176 | 194 |
|
177 | 195 | ;; Functions |
178 | 196 | (defun php-project--validate-php-file-as-template (val) |
@@ -229,6 +247,17 @@ Typically it is `pear', `drupal', `wordpress', `symfony2' and `psr2'.") |
229 | 247 | (t (prog1 nil |
230 | 248 | (warn "php-project-php-file-as-template is unexpected format"))))) |
231 | 249 |
|
| 250 | +(defun php-project-apply-local-variables () |
| 251 | + "Apply php-project variables to local variables." |
| 252 | + (when (null tags-file-name) |
| 253 | + (when (or (and php-project-auto-detect-etags-file |
| 254 | + (null php-project-etags-file)) |
| 255 | + (eq php-project-etags-file t)) |
| 256 | + (let ((tags-file (expand-file-name "TAGS" (php-project-get-root-dir)))) |
| 257 | + (when (file-exists-p tags-file) |
| 258 | + (setq-local php-project-etags-file tags-file)))) |
| 259 | + (when php-project-etags-file |
| 260 | + (setq-local tags-file-name (php-project--eval-bootstrap-scripts php-project-etags-file))))) |
232 | 261 | ;;;###autoload |
233 | 262 | (defun php-project-get-bootstrap-scripts () |
234 | 263 | "Return list of bootstrap script." |
|
0 commit comments