branch: master commit bb737d8f89bac781771849db33b1832fa34cc4ca Author: Dmitry Gutov <dgu...@yandex.ru> Commit: Dmitry Gutov <dgu...@yandex.ru>
Determine exit-function's status using completion-boundaries Closes #935 --- NEWS.md | 2 ++ company-capf.el | 12 +++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/NEWS.md b/NEWS.md index 7c01c1f..135c9e6 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,8 @@ ## Next +* `company-capf`'s `:exit-function` handling has been improved + ([#935](https://github.com/company-mode/company-mode/issues/935)). * New user option `company-clang-use-compile-flags-txt` ([#933](https://github.com/company-mode/company-mode/issues/933)). * Support for completion style specific sorting (Emacs 27 feature). diff --git a/company-capf.el b/company-capf.el index 5b7a1f3..cb30a80 100644 --- a/company-capf.el +++ b/company-capf.el @@ -188,18 +188,20 @@ so we can't just use the preceding variable instead.") (defun company--capf-post-completion (arg) (let* ((res company-capf--current-completion-data) (exit-function (plist-get (nthcdr 4 res) :exit-function)) - (table (nth 3 res)) - (pred (plist-get (nthcdr 4 res) :predicate))) + (table (nth 3 res))) (if exit-function - ;; Follow the example of `completion--done'. + ;; We can more or less know when the user is done with completion, + ;; so we do something different than `completion--done'. (funcall exit-function arg ;; FIXME: Should probably use an additional heuristic: ;; completion-at-point doesn't know when the user picked a ;; particular candidate explicitly (it only checks whether ;; further completions exist). Whereas company user can press ;; RET (or use implicit completion with company-tng). - (if (eq (try-completion arg table pred) t) - 'finished 'sole))))) + (if (= (car (completion-boundaries arg table nil "")) + (length arg)) + 'sole + 'finished))))) (provide 'company-capf)