emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/php-mode ece3dd51ce 10/15: Add php-ide-mode-functions inst


From: ELPA Syncer
Subject: [nongnu] elpa/php-mode ece3dd51ce 10/15: Add php-ide-mode-functions instead of php-ide-mode-hooks
Date: Sat, 18 Mar 2023 18:01:27 -0400 (EDT)

branch: elpa/php-mode
commit ece3dd51ce8ef349335042097a836ef4cd2ff03a
Author: USAMI Kenta <tadsan@zonu.me>
Commit: USAMI Kenta <tadsan@zonu.me>

    Add php-ide-mode-functions instead of php-ide-mode-hooks
---
 lisp/php-ide.el | 30 ++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/lisp/php-ide.el b/lisp/php-ide.el
index 8d6cc758a6..bd61e6ada3 100644
--- a/lisp/php-ide.el
+++ b/lisp/php-ide.el
@@ -57,9 +57,18 @@
 ;;
 ;; Put follows code into your .emacs (~/.emacs.d/init.el) file:
 ;;
-;;     (defun my-php-mode-setup ()
+;;     (defun init-php-mode-setup ()
 ;;       (add-hook 'hack-local-variables-hook #'php-ide-mode t t))
 ;;
+;;     (defun init-php-ide-mode-setup (feature activate)
+;;         (pcase feature
+;;           (`lsp-bridge
+;;            (if activate
+;;                (progn (yas-minor-mode +1)
+;;                       (corfu-mode -1))
+;;              (yas-minor-mode -1)
+;;              (corfu-mode +1)))))
+;;
 ;;     (with-eval-after-load 'php-ide
 ;;       (custom-set-variables
 ;;        '(php-ide-features . 'eglot) ;; and/or 'none, 'phpactor, 'lsp-mode
@@ -67,7 +76,8 @@
 ;;        ;; If you want to hide php-ide-mode from the mode line, set an empty 
string
 ;;        '(php-ide-mode-lighter ""))
 ;;
-;;       (add-hook 'php-mode #'my-php-mode-setup))
+;;       (add-hook 'php-mode-hook #'init-php-mode-setup)
+;;       (add-hook 'php-ide-mode-functions #'init-php-ide-mode-setup))
 ;;
 ;; If you don't enable IDE support by default, set '(php-ide-feature 'none)
 ;;
@@ -168,7 +178,19 @@
   :type 'string
   :safe #'stringp)
 
-(defvar php-ide-mode-hooks nil)
+(defcustom php-ide-mode-functions nil
+  "Hook functions called when before activating or deactivating PHP-IDE.
+Notice that two arguments (FEATURE ACTIVATE) are given.
+
+FEATURE: A symbol, like 'lsp-mode.
+ACTIVATE: T is given when activeting, NIL when deactivating PHP-IDE."
+  :tag "PHP-IDE Mode Functions"
+  :group 'php-ide
+  :type '(repeat function)
+  :safe (lambda (functions)
+          (and (listp functions)
+               (cl-loop for function in functions
+                        always (functionp function)))))
 
 ;;;###autoload
 (define-minor-mode php-ide-mode
@@ -182,11 +204,11 @@
                   ide-features
                   (mapconcat (lambda (feature) (concat "'" (symbol-name 
feature)))
                              (php-ide--avilable-features) ", ")))
-    (run-hooks 'php-ide-mode-hooks)
     (cl-loop for feature in ide-features
              for ide-plist = (cdr-safe (assq feature php-ide-feature-alist))
              do (if (null ide-plist)
                     (message "Please set `php-ide-feature' variable in 
.dir-locals.el or custom variable")
+                  (run-hook-with-args 'php-ide-mode-functions feature 
php-ide-mode)
                   (if php-ide-mode
                       (php-ide--activate-buffer feature ide-plist)
                     (php-ide--deactivate-buffer ide-plist))))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]