|
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") |
@@ -107,6 +120,7 @@ STRING |
107 | 120 | (defvar-local php-project-etags-file nil) |
108 | 121 | (put 'php-project-etags-file 'safe-local-variable |
109 | 122 | #'(lambda (v) (or (functionp v) |
| 123 | + (eq v t) |
110 | 124 | (php-project--eval-bootstrap-scripts v)))) |
111 | 125 |
|
112 | 126 | (defvar-local php-project-bootstrap-scripts nil |
@@ -235,9 +249,15 @@ Typically it is `pear', `drupal', `wordpress', `symfony2' and `psr2'.") |
235 | 249 |
|
236 | 250 | (defun php-project-apply-local-variables () |
237 | 251 | "Apply php-project variables to local variables." |
238 | | - (when (and php-project-etags-file (null tags-file-name)) |
239 | | - (setq-local tags-file-name (php-project--eval-bootstrap-scripts php-project-etags-file)))) |
240 | | - |
| 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))))) |
241 | 261 | ;;;###autoload |
242 | 262 | (defun php-project-get-bootstrap-scripts () |
243 | 263 | "Return list of bootstrap script." |
|
0 commit comments