0

I use the following snippet to set up company-mode for text files and derived modes. I use a curated word list as the source for company-ispell.

(progn
  (defun sb/company-text-mode ()
    "Add backends for text completion in company mode."
    (setq-local company-minimum-prefix-length 2)
    (set (make-local-variable 'company-backends)
         '(company-files
           ;; FIXME: Delete duplicates
           ;; Give priority to dabbrev completions over ispell
           (:separate
            company-dabbrev
            company-ispell)
           )))

  (dolist (hook '(text-mode-hook)) ; Extends to derived modes like `markdown-mode' and `org-mode'
    (add-hook hook #'sb/company-text-mode)))

How can I avoid duplicates from appearing in company popups in cases where company-dabbrev returns a value? Thanks.

1 Answer 1

1

You may try out setting company-transformers to delete-dups, as was suggested in one of the Company threads:

(setq-local company-transformers '(delete-dups)
            company-backends '(company-files (:separate company-dabbrev company-ispell)))

It'd be interesting to know if you get any performance implications in case of large ispell backend candidates list.

2
  • Thanks. It should be delete-dups, isn't it? Oct 5, 2021 at 14:43
  • I initially suggested delete-consecutive-dups for the case without :separate keyword. Now the answer is updated.
    – Y. E.
    Oct 6, 2021 at 13:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.