branch: master
commit 2c2383319ff5fbafdf0533c947f431258c7e72e5
Merge: 2bd76a6 4711695
Author: Dmitry Gutov <dgu...@yandex.ru>
Commit: Dmitry Gutov <dgu...@yandex.ru>

    Merge commit '4711695af3df93f1bbceee165c505fea5bfc49ac' from company
---
 packages/company/NEWS.md    |  5 +++++
 packages/company/company.el | 15 ++++++++++++---
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/packages/company/NEWS.md b/packages/company/NEWS.md
index 2db3dcf..520766f 100644
--- a/packages/company/NEWS.md
+++ b/packages/company/NEWS.md
@@ -1,5 +1,10 @@
 # History of user-visible changes
 
+## 2018-02-23 (0.9.6)
+
+* Workaround for Emacs' ([bug#23980](https://debbugs.gnu.org/23980)) triggered
+  in combination with Flyspell.
+
 ## 2018-02-18 (0.9.5)
 
 * The most common case of tooltip flickering with asynchronous backends (and
diff --git a/packages/company/company.el b/packages/company/company.el
index 8ea1db0..4a86c83 100644
--- a/packages/company/company.el
+++ b/packages/company/company.el
@@ -5,7 +5,7 @@
 ;; Author: Nikolaj Schumacher
 ;; Maintainer: Dmitry Gutov <dgu...@yandex.ru>
 ;; URL: http://company-mode.github.io/
-;; Version: 0.9.5
+;; Version: 0.9.6
 ;; Keywords: abbrev, convenience, matching
 ;; Package-Requires: ((emacs "24.3"))
 
@@ -1240,8 +1240,12 @@ can retrieve meta-data for them."
            (when (eq res 'none)
              (push 'company-foo unread-command-events))
            (setq res candidates)))
-        (while (and (eq res 'none)
-                    (sit-for 0.5 t)))
+        (if (company--flyspell-workaround-p)
+            (while (and (eq res 'none)
+                        (not (input-pending-p)))
+              (sleep-for company-async-wait))
+          (while (and (eq res 'none)
+                      (sit-for 0.5 t))))
         (while (member (car unread-command-events)
                        '(company-foo (t . company-foo)))
           (pop unread-command-events))
@@ -1249,6 +1253,11 @@ can retrieve meta-data for them."
             (and (consp res) res)
           (setq res 'exited))))))
 
+(defun company--flyspell-workaround-p ()
+  ;; https://debbugs.gnu.org/23980
+  (and (bound-and-true-p flyspell-mode)
+       (version< emacs-version "27")))
+
 (defun company--preprocess-candidates (candidates)
   (cl-assert (cl-every #'stringp candidates))
   (unless (company-call-backend 'sorted)

Reply via email to