2

I use gtags, jedi and dabbrev for python. Sometimes the duplicates get a bit annoying. I read that using :with should sort out the duplicates problem. However, it does not... Is there a better solution that this? :

(add-hook 'python-mode-hook
          (lambda ()
            (set (make-local-variable 'company-backends)
                 '((company-gtags :with company-jedi company-dabbrev-code)))))

In the Company documentation, Company Backends section there is a line that reads: "‘duplicates’: If non-nil, company will take care of removing duplicates from the list.". I just can't figure out how to enable it.

  • I use `anaconda-mode` and using `company-anaconda` along with `company-dabbrev-code` created a lot of duplicates for me as well. Deleting `company-dabbrev-code` fixed the problem for me. `anaconda` backend does the job of `dabbrev-code` as well. I'm not sure `jedi` though – Chakravarthy Raghunandan Oct 22 '16 at 12:01
  • I like the dabbrev's functionality of scanning other buffers as well. Does anaconda do that too? – Damian Chrzanowski Oct 22 '16 at 17:18
  • I dont think `anaconda-mode` does that. But, if you import said file, you will get company completions for that imported file, otherwise not. – Chakravarthy Raghunandan Oct 22 '16 at 17:31
  • https://emacs.stackexchange.com/questions/68733/delete-duplicates-from-company-popups/68735#68735 – Y. E. Jan 02 '22 at 15:34

1 Answers1

2

Depending on what causes the duplicates, you might be talking about https://github.com/company-mode/company-mode/issues/413, https://github.com/company-mode/company-mode/issues/285 (which are actual bugs/design problems, though they only should come up with certain customizations), or about having the same symbols show up twice coming from different backends, once with annotation and once without (for example).

We count such completions as different, which sometimes is a good choice (for certain kinds of backend combinations), and sometimes not so much. Perhaps we could do better by default (detailed proposals welcome), but until then, this answer is as good workaround as any: Delete duplicates from company popups

Dmitry
  • 3,508
  • 15
  • 20
  • Yes I used the last link and then https://github.com/company-mode/company-mode/issues/528#issuecomment-752346089 (Frustrating as so much code to make company useable - whilst other editors/IDE just work - also I had copied much of jojojames' work here but not all) – mmmmmm Jan 06 '22 at 07:26
  • It is usable out of the box. Note that we are discussing custom configurations here; it shouldn't be a problem that to make a custom setup work to your preference you'd need to tweak it a little. – Dmitry Jan 06 '22 at 22:58
  • I have a solution in mind for #413, but if your problem is #285, it's more of a design choice. Doesn't the answer to the question I linked here work for you? It's one extra line of configuration. – Dmitry Jan 06 '22 at 22:59
  • I also wanted yasnippet in the popup and so had used parts of jojojames's code - now I use the whole lot. (The yasnippets are separate but the dabbrev and capf completions are now not duplicated I can live with that) – mmmmmm Jan 07 '22 at 07:10
  • On attempting the short code it seems OK after editing to use :with etc - The issue I think I had was that I need to understand a lot of the details of company before I got a working version - ie your example use :separate which is the opposite of what I want which is :with jojojames's code even though much more complex can just be cut and paste – mmmmmm Jan 07 '22 at 15:54
  • That example should work with both `:separate` and `:with`. But yeah, if you're customizing the behavior, you might need to do some reading. – Dmitry Jan 07 '22 at 18:27
  • I'd be happy for yasnippet, etc, to be configured ootb, but so far there is no single agreed-upon configuration like that. – Dmitry Jan 07 '22 at 18:28