[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 307b620 59/78: Simplify how async backends are called (WIP
From: |
Dmitry Gutov |
Subject: |
[elpa] master 307b620 59/78: Simplify how async backends are called (WIP) |
Date: |
Sun, 18 Feb 2018 07:40:26 -0500 (EST) |
branch: master
commit 307b62063c2376e6432d7ed9c4e79f25c50edabf
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>
Simplify how async backends are called (WIP)
Aiming to fix #510 and #654, but no visible improvement yet.
---
company-clang.el | 4 +++-
company.el | 37 ++++++++++++-------------------------
test/async-tests.el | 1 +
3 files changed, 16 insertions(+), 26 deletions(-)
diff --git a/company-clang.el b/company-clang.el
index 90a372e..43ecc8e 100644
--- a/company-clang.el
+++ b/company-clang.el
@@ -343,7 +343,9 @@ passed via standard input."
(if (string-match "\\`:[^:]" anno)
(company-template-objc-templatify anno)
(company-template-c-like-templatify
- (concat arg anno))))))))
+ (concat arg anno))))))
+ ;; FIXME: Remove, this is just for testing.
+ (no-cache t)))
(provide 'company-clang)
;;; company-clang.el ends here
diff --git a/company.el b/company.el
index 68fcaaa..173266d 100644
--- a/company.el
+++ b/company.el
@@ -1220,36 +1220,23 @@ can retrieve meta-data for them."
(let* ((non-essential (not (company-explicit-action-p)))
(c (if company--manual-action
(company-call-backend 'candidates prefix)
- (company-call-backend-raw 'candidates prefix)))
- res)
+ (company-call-backend-raw 'candidates prefix))))
(if (not (eq (car c) :async))
c
- (let ((buf (current-buffer))
- (win (selected-window))
- (tick (buffer-chars-modified-tick))
- (pt (point))
- (backend company-backend))
+ (let ((res 'none))
(funcall
(cdr c)
(lambda (candidates)
- (if (not (and candidates (eq res 'done)))
- ;; There's no completions to display,
- ;; or the fetcher called us back right away.
- (setq res candidates)
- (setq company-backend backend
- company-candidates-cache
- (list (cons prefix
- (company--preprocess-candidates candidates))))
- (unwind-protect
- (company-idle-begin buf win tick pt)
- (unless company-candidates
- (setq company-backend nil
- company-candidates-cache nil)))))))
- ;; FIXME: Relying on the fact that the callers
- ;; will interpret nil as "do nothing" is shaky.
- ;; A throw-catch would be one possible improvement.
- (or res
- (progn (setq res 'done) nil)))))
+ (setq res candidates)))
+ (while (and (eq res 'none)
+ (not (input-pending-p t)))
+ ;; FIXME: This still leads to flickers.
+ ;; Apparently sit-for triggers redisplay anyway.
+ (sleep-for company-async-wait))
+ ;; (if (listp res)
+ ;; (message "res len is %s" (length res))
+ ;; (message "none"))
+ (and (consp res) res)))))
(defun company--preprocess-candidates (candidates)
(cl-assert (cl-every #'stringp candidates))
diff --git a/test/async-tests.el b/test/async-tests.el
index 48ebdfb..889ff13 100644
--- a/test/async-tests.el
+++ b/test/async-tests.el
@@ -66,6 +66,7 @@
(let (company-frontends
company-transformers
(company-backends (list 'company-async-backend)))
+ ;; FIXME: Remove such tests?
(company-idle-begin (current-buffer) (selected-window)
(buffer-chars-modified-tick) (point))
(should (null company-candidates))
- [elpa] master 75b4daa 37/78: Merge pull request #737 from iquiw/container-based-ci, (continued)
- [elpa] master 75b4daa 37/78: Merge pull request #737 from iquiw/container-based-ci, Dmitry Gutov, 2018/02/18
- [elpa] master 0f70fee 47/78: Add keywords for swift-mode, Dmitry Gutov, 2018/02/18
- [elpa] master 10807eb 48/78: Merge pull request #750 from jojojames/master, Dmitry Gutov, 2018/02/18
- [elpa] master 556fe45 45/78: Specify type, Dmitry Gutov, 2018/02/18
- [elpa] master e97d26f 51/78: Specify :type for company-dabbrev -ignore-case and -downcase, Dmitry Gutov, 2018/02/18
- [elpa] master d789f26 54/78: Merge pull request #754 from jabranham/fix-defcustom, Dmitry Gutov, 2018/02/18
- [elpa] master 3959af9 52/78: Specify :type for company-semantic-begin-after-member-access, Dmitry Gutov, 2018/02/18
- [elpa] master 7c5408c 57/78: company-clang--start-process: Kill the existing process, if any, Dmitry Gutov, 2018/02/18
- [elpa] master 0efc9f3 58/78: Reindent, Dmitry Gutov, 2018/02/18
- [elpa] master b22df34 60/78: Use inhibit-redisplay, Dmitry Gutov, 2018/02/18
- [elpa] master 307b620 59/78: Simplify how async backends are called (WIP),
Dmitry Gutov <=
- [elpa] master 82d41b7 70/78: Avoid an extra redisplay call, Dmitry Gutov, 2018/02/18
- [elpa] master 4004c7f 42/78: Merge pull request #748 from nikital/tng-dont-require-match, Dmitry Gutov, 2018/02/18
- [elpa] master 6ddeae2 43/78: Rework Clang version handling, Dmitry Gutov, 2018/02/18
- [elpa] master 0bd111d 49/78: Add keywords for kotlin-mode, Dmitry Gutov, 2018/02/18
- [elpa] master f3910a2 71/78: Add a comment justifying the duplication [ci skip], Dmitry Gutov, 2018/02/18
- [elpa] master b079bd2 75/78: Revert "Break idle re-starting loop", Dmitry Gutov, 2018/02/18
- [elpa] master 7cc0901 77/78: Release 0.9.5, Dmitry Gutov, 2018/02/18
- [elpa] master d033112 28/78: Merge pull request #720 from aaronjensen/abort-dabbrev-on-input, Dmitry Gutov, 2018/02/18
- [elpa] master 3b5415a 41/78: company-tng: default config: Disable company-require-match, Dmitry Gutov, 2018/02/18
- [elpa] master 9b4488f 69/78: Rephrase, Dmitry Gutov, 2018/02/18