|
57 | 57 | ;;
|
58 | 58 | ;; Put follows code into your .emacs (~/.emacs.d/init.el) file:
|
59 | 59 | ;;
|
60 |
| -;; (defun my-php-mode-setup () |
| 60 | +;; (defun init-php-mode-setup () |
61 | 61 | ;; (add-hook 'hack-local-variables-hook #'php-ide-mode t t))
|
62 | 62 | ;;
|
| 63 | +;; (defun init-php-ide-mode-setup (feature activate) |
| 64 | +;; (pcase feature |
| 65 | +;; (`lsp-bridge |
| 66 | +;; (if activate |
| 67 | +;; (progn (yas-minor-mode +1) |
| 68 | +;; (corfu-mode -1)) |
| 69 | +;; (yas-minor-mode -1) |
| 70 | +;; (corfu-mode +1))))) |
| 71 | +;; |
63 | 72 | ;; (with-eval-after-load 'php-ide
|
64 | 73 | ;; (custom-set-variables
|
65 | 74 | ;; '(php-ide-features . 'eglot) ;; and/or 'none, 'phpactor, 'lsp-mode
|
66 | 75 | ;; '(php-ide-eglot-executable "psalm-language-server") ;; or "intelephense", '("php" "vendor/bin/path/to/server")
|
67 | 76 | ;; ;; If you want to hide php-ide-mode from the mode line, set an empty string
|
68 | 77 | ;; '(php-ide-mode-lighter ""))
|
69 | 78 | ;;
|
70 |
| -;; (add-hook 'php-mode #'my-php-mode-setup)) |
| 79 | +;; (add-hook 'php-mode-hook #'init-php-mode-setup) |
| 80 | +;; (add-hook 'php-ide-mode-functions #'init-php-ide-mode-setup)) |
71 | 81 | ;;
|
72 | 82 | ;; If you don't enable IDE support by default, set '(php-ide-feature 'none)
|
73 | 83 | ;;
|
|
168 | 178 | :type 'string
|
169 | 179 | :safe #'stringp)
|
170 | 180 |
|
171 |
| -(defvar php-ide-mode-hooks nil) |
| 181 | +(defcustom php-ide-mode-functions nil |
| 182 | + "Hook functions called when before activating or deactivating PHP-IDE. |
| 183 | +Notice that two arguments (FEATURE ACTIVATE) are given. |
| 184 | +
|
| 185 | +FEATURE: A symbol, like 'lsp-mode. |
| 186 | +ACTIVATE: T is given when activeting, NIL when deactivating PHP-IDE." |
| 187 | + :tag "PHP-IDE Mode Functions" |
| 188 | + :group 'php-ide |
| 189 | + :type '(repeat function) |
| 190 | + :safe (lambda (functions) |
| 191 | + (and (listp functions) |
| 192 | + (cl-loop for function in functions |
| 193 | + always (functionp function))))) |
172 | 194 |
|
173 | 195 | ;;;###autoload
|
174 | 196 | (define-minor-mode php-ide-mode
|
|
182 | 204 | ide-features
|
183 | 205 | (mapconcat (lambda (feature) (concat "'" (symbol-name feature)))
|
184 | 206 | (php-ide--avilable-features) ", ")))
|
185 |
| - (run-hooks 'php-ide-mode-hooks) |
186 | 207 | (cl-loop for feature in ide-features
|
187 | 208 | for ide-plist = (cdr-safe (assq feature php-ide-feature-alist))
|
188 | 209 | do (if (null ide-plist)
|
189 | 210 | (message "Please set `php-ide-feature' variable in .dir-locals.el or custom variable")
|
| 211 | + (run-hook-with-args 'php-ide-mode-functions feature php-ide-mode) |
190 | 212 | (if php-ide-mode
|
191 | 213 | (php-ide--activate-buffer feature ide-plist)
|
192 | 214 | (php-ide--deactivate-buffer ide-plist))))))
|
|
0 commit comments