3

I am writing in LaTeX at the moment and I want to use company-mode for word completion. I found this solution: https://emacs.stackexchange.com/a/18522.

I was thinking about using the ispell dictionary instead, then I can also switch to another language for other documents.

I tried the code below, but when trying with company-complete I just get No completion found with almost any word.

(require 'ispell)
(setq ispell-dictionary "en_US")

(require 'company)
(add-hook 'after-init-hook 'global-company-mode)
(add-to-list 'company-backends 'company-ispell)
(setq company-ispell-dictionary ispell-dictionary)

Does company-ispell only work with plain txt dictionaries?

Wuff
  • 185
  • 1
  • 9

1 Answers1

4

You need provide a "plain word-list dictionary".

Step 1, Check the code of company-ispell, it actually calls ispell-lookup-words.

Step 2, check ispell-lookup-words documentation:

"Optional second argument contains the dictionary to use; the default is ‘ispell-alternate-dictionary’, overridden by ‘ispell-complete-word-dict’ if defined."

Step 3, check ispell-alternate-dictionary documentation:

"Alternate plain word-list dictionary for spelling help."

So binary dictionaries won't work.

BTW, Emacs will automatically find readable dictionary for ispell-alternate-dictionary on macOS/Linux. So usually you don't need any extra setup.

If you are using Windows, here is a sample dictionary: https://github.com/redguardtoo/emacs.d/blob/e9c656592d5ad89ee008764903972d0aeda2339b/misc/english-words.txt

chen bin
  • 4,781
  • 18
  • 36
  • Perfect explanation! Didn't come across the ispell-alternate-dictionary documentation. Thanks for helping me out! Seems that now I need to search for plain word-list dictionaries for my other languages. – Wuff Jul 11 '18 at 10:55
  • 1
    Note that the word list needs to be sorted (case insensitive) I didn't see this documented anywhere, although I might have missed it. See this answer for an example configuration that generates the word-list: https://emacs.stackexchange.com/a/54742/2418 – ideasman42 Jan 07 '20 at 23:18