branch: externals/company
commit eeba45b8c800533d53869618d1e00ebb23bcde20
Merge: 035e38b835 917a40cd57
Author: Dmitry Gutov <dmi...@gutov.dev>
Commit: GitHub <nore...@github.com>

    Merge pull request #1479 from company-mode/while-no-input-opt-in
    
    Make the use of while-no-input in company-capf opt-in
---
 NEWS.md         | 10 ++++------
 company-capf.el |  6 ++++--
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/NEWS.md b/NEWS.md
index 4c518585ed..38f8cb95a1 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -4,13 +4,11 @@
 
 * Improved behavior when user types new character while completion is being
   computed: better performance, less blinking (in the rare cases when it still
-  happened). The improvement extends to native async backends and to
+  happened). This affects native async backends and is opt-in with
   `company-capf`.
-* As such `company-capf` now interrupts computation on new user
-  input. Completion tables that are incompatible with this behavior should get
-  updated: bind `inhibit-quit` to non-nil around their sensitive sections, or
-  simply around the whole implementation (e.g. using
-  `cape-capf-noninterruptible` from [cape](https://github.com/minad/cape/)).
+* For that, `company-capf` supports interrupting computation on new user
+  input. Completion functions that want to take advantage of this behavior
+  should include `:company-use-while-no-input` in the returned properties list.
 * `company-elisp` has been removed.  It's not needed since Emacs 24.4, with all
   of its features having been incorporated into the built-in Elisp completion.
 * `company-files` shows shorter completions.  Previously, the popup spanned
diff --git a/company-capf.el b/company-capf.el
index 2543f3d8d2..8d796f5f01 100644
--- a/company-capf.el
+++ b/company-capf.el
@@ -189,10 +189,12 @@ so we can't just use the preceding variable instead.")
                      table pred))))
     (company-capf--save-current-data res meta)
     (when res
-      (let* ((candidates (company-capf--candidates-1 input table pred
+      (let* ((interrupt (plist-get (nthcdr 4 res) :company-use-while-no-input))
+             (candidates (company-capf--candidates-1 input table pred
                                                      (length input)
                                                      meta
-                                                     non-essential))
+                                                     (and non-essential
+                                                          interrupt)))
              (sortfun (cdr (assq 'display-sort-function meta)))
              (last (last candidates))
              (base-size (and (numberp (cdr last)) (cdr last))))

Reply via email to