Skip to content

Commit 795466c

Browse files
committed
Add php-project-apply-local-variables and apply it in php-mode
1 parent d96bc94 commit 795466c

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

php-mode.el

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,12 @@ In that case set to `NIL'."
342342
:tag "PHP Mode Disable C Mode Hook"
343343
:type 'boolean)
344344

345+
(defcustom php-mode-enable-project-local-variable t
346+
"When set to `T', apply project local variable to buffer local variable."
347+
:group 'php-mode
348+
:tag "PHP Mode Enable Project Local Variable"
349+
:type 'boolean)
350+
345351
(defun php-mode-version ()
346352
"Display string describing the version of PHP Mode."
347353
(interactive)
@@ -1116,6 +1122,11 @@ After setting the stylevars run hooks according to STYLENAME
11161122
(php-set-style (symbol-name coding-style)))
11171123
(remove-hook 'hack-local-variables-hook #'php-mode-set-style-delay)))))
11181124

1125+
(defun php-mode-set-local-variable-delay ()
1126+
"Set local variable from php-project."
1127+
(php-project-apply-local-variables)
1128+
(remove-hook 'hack-local-variables-hook #'php-mode-set-local-variable-delay))
1129+
11191130
(defvar php-mode-syntax-table
11201131
(let ((table (make-syntax-table)))
11211132
(c-populate-syntax-table table)
@@ -1169,6 +1180,9 @@ After setting the stylevars run hooks according to STYLENAME
11691180
;; PHP vars are case-sensitive
11701181
(setq case-fold-search t)
11711182

1183+
(when php-mode-enable-project-local-variable
1184+
(add-hook 'hack-local-variables-hook #'php-mode-set-local-variable-delay t t))
1185+
11721186
;; When php-mode-enable-project-coding-style is set, it is delayed by hook.
11731187
;; Since it depends on the timing at which the file local variable is set.
11741188
;; File local variables are set after initialization of major mode except `run-hook' is complete.

php-project.el

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,11 @@ Typically it is `pear', `drupal', `wordpress', `symfony2' and `psr2'.")
233233
(t (prog1 nil
234234
(warn "php-project-php-file-as-template is unexpected format")))))
235235

236+
(defun php-project-apply-local-variables ()
237+
"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+
236241
;;;###autoload
237242
(defun php-project-get-bootstrap-scripts ()
238243
"Return list of bootstrap script."

0 commit comments

Comments
 (0)