Skip to content

Commit 337d205

Browse files
committed
Add php-ide-mode-functions instead of php-ide-mode-hooks
1 parent a01bb22 commit 337d205

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

Diff for: lisp/php-ide.el

+27-4
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,28 @@
5757
;;
5858
;; Put follows code into your .emacs (~/.emacs.d/init.el) file:
5959
;;
60-
;; (defun my-php-mode-setup ()
60+
;; (defun init-php-mode-setup ()
6161
;; (add-hook 'hack-local-variables-hook #'php-ide-mode t t))
6262
;;
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+
;; (add-hook 'php-ide-mode-functions #'init-php-ide-mode)
72+
;;
6373
;; (with-eval-after-load 'php-ide
6474
;; (custom-set-variables
6575
;; '(php-ide-features . 'eglot) ;; and/or 'none, 'phpactor, 'lsp-mode
6676
;; '(php-ide-eglot-executable "psalm-language-server") ;; or "intelephense", '("php" "vendor/bin/path/to/server")
6777
;; ;; If you want to hide php-ide-mode from the mode line, set an empty string
6878
;; '(php-ide-mode-lighter ""))
6979
;;
70-
;; (add-hook 'php-mode #'my-php-mode-setup))
80+
;; (add-hook 'php-mode-hook #'init-php-mode-setup)
81+
;; (add-hook 'php-ide-mode-functions #'init-php-ide-mode-setup))
7182
;;
7283
;; If you don't enable IDE support by default, set '(php-ide-feature 'none)
7384
;;
@@ -168,7 +179,19 @@
168179
:type 'string
169180
:safe #'stringp)
170181

171-
(defvar php-ide-mode-hooks nil)
182+
(defcustom php-ide-mode-functions nil
183+
"Hook functions called when before activating or deactivating PHP-IDE.
184+
Notice that two arguments (FEATURE ACTIVATE) are given.
185+
186+
FEATURE: A symbol, like 'lsp-mode.
187+
ACTIVATE: T is given when activeting, NIL when deactivating PHP-IDE."
188+
:tag "PHP-IDE Mode Functions"
189+
:group 'php-ide
190+
:type '(repeat function)
191+
:safe (lambda (functions)
192+
(and (listp functions)
193+
(cl-loop for function in functions
194+
always (functionp function)))))
172195

173196
;;;###autoload
174197
(define-minor-mode php-ide-mode
@@ -182,11 +205,11 @@
182205
ide-features
183206
(mapconcat (lambda (feature) (concat "'" (symbol-name feature)))
184207
(php-ide--avilable-features) ", ")))
185-
(run-hooks 'php-ide-mode-hooks)
186208
(cl-loop for feature in ide-features
187209
for ide-plist = (cdr-safe (assq feature php-ide-feature-alist))
188210
do (if (null ide-plist)
189211
(message "Please set `php-ide-feature' variable in .dir-locals.el or custom variable")
212+
(run-hook-with-args 'php-ide-mode-functions feature php-ide-mode)
190213
(if php-ide-mode
191214
(php-ide--activate-buffer feature ide-plist)
192215
(php-ide--deactivate-buffer ide-plist))))))

0 commit comments

Comments
 (0)