9

As the question suggest, I am trying to set up the auto-complete package for writing papers. I have also installed ac-ispell. So far it seems more or less useless, mostly because it is way too slow. Suggestions take several full seconds to appear.

Here are the relevant lines that I currently have in my init, which are based directly on the recommendations in the documentation for these two packages:

(require 'auto-complete-config)
(ac-config-default)
(add-to-list 'ac-modes '(org-mode text-mode LaTeX-mode))

(custom-set-variables
 '(ac-ispell-requires 4)
 '(ac-ispell-fuzzy-limit 2))

(eval-after-load "auto-complete"
  '(progn
     (ac-ispell-setup)))

(add-hook 'git-commit-mode-hook 'ac-ispell-ac-setup)
(add-hook 'mail-mode-hook 'ac-ispell-ac-setup)
(add-hook 'org-mode-hook 'ac-ispell-ac-setup)
(add-hook 'text-mode-hook 'ac-ispell-ac-setup)
(add-hook 'LaTeX-mode-hook 'ac-ispell-ac-setup)

(global-auto-complete-mode t)

In case this helps, the resulting value for ac-sources is (ac-source-ispell ac-source-ispell-fuzzy ac-source-abbrev ac-source-dictionary ac-source-words-in-same-mode-buffers).

If you've had better luck with this then I have, please help!

Tianxiang Xiong
  • 3,848
  • 16
  • 27
Brian Z
  • 2,863
  • 16
  • 22
  • I've now opened an issue for [company-mode](https://github.com/company-mode/company-mode/issues/425) with a very lengthy and detailed version of this question. If I get a good resolution, I will post it as an answer here. – Brian Z Nov 28 '15 at 09:01

2 Answers2

2

Predictive-mode claims to be what you're looking for, though I'm not sure how it compares to more modern completion frameworks like company-mode.

incandescentman
  • 4,111
  • 16
  • 53
2

suppose you use company-mode and you only want to use it in text-mode. org-mode inherits from text-mode, so you don't need setup for both:

(require 'company)
(add-hook 'after-init-hook 'global-company-mode)

(defun text-mode-hook-setup ()
  ;; make `company-backends' local is critcal
  ;; or else, you will have completion in every major mode, that's very annoying!
  (make-local-variable 'company-backends)

  ;; company-ispell is the plugin to complete words
  (add-to-list 'company-backends 'company-ispell)

  ;; OPTIONAL, if `company-ispell-dictionary' is nil, `ispell-complete-word-dict' is used
  ;;  but I prefer hard code the dictionary path. That's more portable.
  (setq company-ispell-dictionary (file-truename "~/.emacs.d/misc/english-words.txt")))

(add-hook 'text-mode-hook 'text-mode-hook-setup)

"english-words.txt" is just a plain text file where lines sorted alphabetically. Every line is a word. (Plain text dictionary is required by ispell, see https://emacs.stackexchange.com/a/42526/ for technical details).

Here is a sample file: https://github.com/redguardtoo/emacs.d/raw/master/misc/english-words.txt

Tested with Emacs24.3, 24.4, company-mode 0.8.12

chen bin
  • 4,781
  • 18
  • 36