branch: externals/company
commit 3f7090f0512104d159d3cbd5d7b756ac637d6286
Author: Dmitry Gutov <[email protected]>
Commit: Dmitry Gutov <[email protected]>

    Make sure minibuffer integration is disabled when global-company-mode is off
---
 company.el | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/company.el b/company.el
index a0d04f4c8b..f6b6c2a85b 100644
--- a/company.el
+++ b/company.el
@@ -1064,12 +1064,12 @@ minibuffer if it's in configured frontends: use 
`company-childframe'."
   :type 'boolean)
 
 ;;;###autoload
-(define-globalized-minor-mode global-company-mode company-mode company-mode-on)
+(define-globalized-minor-mode global-company-mode company-mode company-mode-on
+  (if global-company-mode
+      (add-hook 'minibuffer-setup-hook #'company--minibuffer-on 100)
+    (remove-hook 'minibuffer-setup-hook #'company--minibuffer-on)))
 
 (defun company-mode-on ()
-  (when (and company-global-minibuffer
-             (minibufferp))
-    (add-hook 'minibuffer-setup-hook #'company--minibuffer-on 100))
   (when (and (not (or noninteractive (eq (aref (buffer-name) 0) ?\s)))
              (cond ((eq company-global-modes t)
                     t)
@@ -1079,7 +1079,8 @@ minibuffer if it's in configured frontends: use 
`company-childframe'."
     (company-mode 1)))
 
 (defun company--minibuffer-on ()
-  (when (and (not (try-completion "company-pseudo-tooltip" company-frontends))
+  (when (and company-global-minibuffer
+             (not (try-completion "company-pseudo-tooltip" company-frontends))
              (if (eq company-global-minibuffer t)
                  (local-variable-p 'completion-at-point-functions)
                (funcall company-global-minibuffer)))

Reply via email to