]> code.delx.au - gnu-emacs-elpa/commitdiff
company-elisp-candidates: Deal with duplicates
authorDmitry Gutov <dgutov@yandex.ru>
Fri, 29 Mar 2013 09:26:32 +0000 (13:26 +0400)
committerDmitry Gutov <dgutov@yandex.ru>
Fri, 29 Mar 2013 09:26:32 +0000 (13:26 +0400)
company-elisp.el
company-tests.el

index c862edb8c57d300dc29958bba7314d0478fb7bcd..eec64f44ee3fa22657d4c7eee915da01e7cedafe 100644 (file)
@@ -1,4 +1,4 @@
-;;; company-elisp.el --- A company-mode completion back-end for emacs-lisp-mode
+;;; company-elisp.el --- A company-mode completion back-end for emacs-lisp-mode -*- lexical-binding: t -*-
 
 ;; Copyright (C) 2009, 2011-2012  Free Software Foundation, Inc.
 
@@ -113,7 +113,10 @@ first in the candidates list.")
 (defun company-elisp-candidates (prefix)
   (let* ((predicate (company-elisp-candidates-predicate prefix))
          (locals (company-elisp-locals prefix (eq predicate 'fboundp)))
-         (globals (company-elisp-globals prefix predicate)))
+         (globals (company-elisp-globals prefix predicate))
+         (locals (loop for local in locals
+                       when (not (member local globals))
+                       collect local)))
     (if company-elisp-show-locals-first
         (append (sort locals 'string<)
                 (sort globals 'string<))
index 0ca2e11f5a48b772bc9ca914c9383913c16c1946..4fcb83c4bf582897255380a87ef52f8888eb4dd8 100644 (file)
         (should (eq t (company-elisp 'sorted)))
         (should (equal '("flee" "floo" "flop" "float-pi")
                        (company-elisp-candidates "fl")))))))
+
+(ert-deftest company-elisp-candidates-no-duplicates ()
+  (company-elisp-with-buffer
+    "(let ((float-pi 4))
+       f|)"
+    (let ((obarray [float-pi])
+          (company-elisp-show-locals-first t))
+      (should (equal '("float-pi") (company-elisp-candidates "f"))))))