emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] 22/35: company--multi-backend-adapter-candidates: bind backend lo


From: Dmitry Gutov
Subject: [elpa] 22/35: company--multi-backend-adapter-candidates: bind backend locally
Date: Sat, 19 Apr 2014 10:12:18 +0000

dgutov pushed a commit to branch master
in repository elpa.

commit 90c24b6ac06f722283140a7218223b80bc298e9e
Author: Dmitry Gutov <address@hidden>
Date:   Fri Apr 4 15:53:42 2014 +0300

    company--multi-backend-adapter-candidates: bind backend locally
    
    Fixes #89
---
 company-tests.el |   17 ++++++++++++-----
 company.el       |   12 ++++++------
 2 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/company-tests.el b/company-tests.el
index c2ea35b..9e678af 100644
--- a/company-tests.el
+++ b/company-tests.el
@@ -102,25 +102,32 @@
 
 (ert-deftest company-multi-backend-remembers-candidate-backend ()
   (let ((company-backend
-         (list (lambda (command &optional arg &rest ignore)
+         (list (lambda (command &optional arg)
                  (case command
                    (ignore-case nil)
                    (annotation "1")
                    (candidates '("a" "c"))
                    (post-completion "13")))
-               (lambda (command &optional arg &rest ignore)
+               (lambda (command &optional arg)
                  (case command
                    (ignore-case t)
                    (annotation "2")
                    (candidates '("b" "d"))
-                   (post-completion "42"))))))
+                   (post-completion "42")))
+               (lambda (command &optional arg)
+                 (case command
+                   (annotation "3")
+                   (candidates '("e"))
+                   (post-completion "74"))))))
     (let ((candidates (company-calculate-candidates nil)))
-      (should (equal candidates '("a" "b" "c" "d")))
+      (should (equal candidates '("a" "b" "c" "d" "e")))
       (should (equal t (company-call-backend 'ignore-case)))
       (should (equal "1" (company-call-backend 'annotation (nth 0 
candidates))))
       (should (equal "2" (company-call-backend 'annotation (nth 1 
candidates))))
       (should (equal "13" (company-call-backend 'post-completion (nth 2 
candidates))))
-      (should (equal "42" (company-call-backend 'post-completion (nth 3 
candidates)))))))
+      (should (equal "42" (company-call-backend 'post-completion (nth 3 
candidates))))
+      (should (equal "3" (company-call-backend 'annotation (nth 4 
candidates))))
+      (should (equal "74" (company-call-backend 'post-completion (nth 4 
candidates)))))))
 
 (ert-deftest company-multi-backend-handles-keyword-with ()
   (let ((primo (lambda (command &optional arg)
diff --git a/company.el b/company.el
index 24b00cb..1c255bf 100644
--- a/company.el
+++ b/company.el
@@ -859,12 +859,12 @@ means that `company-mode' is always turned on except in 
`message-mode' buffers."
                      when (equal (funcall backend 'prefix)
                                  prefix)
                      collect (cons (funcall backend 'candidates prefix)
-                                   (lambda (candidates)
-                                     (mapcar
-                                      (lambda (str)
-                                        (propertize str 'company-backend
-                                                    backend))
-                                      candidates))))))
+                                   (let ((b backend))
+                                     (lambda (candidates)
+                                       (mapcar
+                                        (lambda (str)
+                                          (propertize str 'company-backend b))
+                                        candidates)))))))
     (when (equal (funcall (car backends) 'prefix) prefix)
       ;; Small perf optimization: don't tag the candidates received
       ;; from the first backend in the group.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]