Skip to content

Commit ece3dd5

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

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

Diff for: lisp/php-ide.el

+26-4
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,27 @@
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+
;;
6372
;; (with-eval-after-load 'php-ide
6473
;; (custom-set-variables
6574
;; '(php-ide-features . 'eglot) ;; and/or 'none, 'phpactor, 'lsp-mode
6675
;; '(php-ide-eglot-executable "psalm-language-server") ;; or "intelephense", '("php" "vendor/bin/path/to/server")
6776
;; ;; If you want to hide php-ide-mode from the mode line, set an empty string
6877
;; '(php-ide-mode-lighter ""))
6978
;;
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))
7181
;;
7282
;; If you don't enable IDE support by default, set '(php-ide-feature 'none)
7383
;;
@@ -168,7 +178,19 @@
168178
:type 'string
169179
:safe #'stringp)
170180

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)))))
172194

173195
;;;###autoload
174196
(define-minor-mode php-ide-mode
@@ -182,11 +204,11 @@
182204
ide-features
183205
(mapconcat (lambda (feature) (concat "'" (symbol-name feature)))
184206
(php-ide--avilable-features) ", ")))
185-
(run-hooks 'php-ide-mode-hooks)
186207
(cl-loop for feature in ide-features
187208
for ide-plist = (cdr-safe (assq feature php-ide-feature-alist))
188209
do (if (null ide-plist)
189210
(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)
190212
(if php-ide-mode
191213
(php-ide--activate-buffer feature ide-plist)
192214
(php-ide--deactivate-buffer ide-plist))))))

0 commit comments

Comments
 (0)