branch: externals/company commit e23eccdb37173971a54c5901c736513960486ff4 Author: Dmitry Gutov <dmi...@gutov.dev> Commit: Dmitry Gutov <dmi...@gutov.dev>
company-capf: Add property :company-use-while-no-input #1468 --- company-capf.el | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/company-capf.el b/company-capf.el index 0173a611cc..09ba50b1a1 100644 --- a/company-capf.el +++ b/company-capf.el @@ -1,6 +1,6 @@ ;;; company-capf.el --- company-mode completion-at-point-functions backend -*- lexical-binding: t -*- -;; Copyright (C) 2013-2023 Free Software Foundation, Inc. +;; Copyright (C) 2013-2024 Free Software Foundation, Inc. ;; Author: Stefan Monnier <monn...@iro.umontreal.ca> @@ -189,9 +189,11 @@ so we can't just use the preceding variable instead.") table pred)))) (company-capf--save-current-data res meta) (when res - (let* ((candidates (completion-all-completions 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)) + meta + interrupt)) (sortfun (cdr (assq 'display-sort-function meta))) (last (last candidates)) (base-size (and (numberp (cdr last)) (cdr last)))) @@ -207,6 +209,17 @@ so we can't just use the preceding variable instead.") candidates)) candidates))))) +(defun company-capf--candidates-1 (input table pred len meta interrupt-on-input) + (if (not interrupt-on-input) + (completion-all-completions input table pred len meta) + (let (res) + (and (while-no-input + (setq res + (completion-all-completions input table pred len meta)) + nil) + (throw 'interrupted 'new-input)) + res))) + (defun company--capf-post-completion (arg) (let* ((res company-capf--current-completion-data) (exit-function (plist-get (nthcdr 4 res) :exit-function))