From 36108c9f82d401113c2b87c18576e9835bd44e1c Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Fri, 29 Mar 2013 13:26:32 +0400 Subject: [PATCH] company-elisp-candidates: Deal with duplicates --- company-elisp.el | 7 +++++-- company-tests.el | 8 ++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/company-elisp.el b/company-elisp.el index c862edb8c..eec64f44e 100644 --- a/company-elisp.el +++ b/company-elisp.el @@ -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<)) diff --git a/company-tests.el b/company-tests.el index 0ca2e11f5..4fcb83c4b 100644 --- a/company-tests.el +++ b/company-tests.el @@ -320,3 +320,11 @@ (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")))))) -- 2.39.2