1 ;;; company-ispell.el --- company-mode completion backend using Ispell
3 ;; Copyright (C) 2009-2011, 2013-2015 Free Software Foundation, Inc.
5 ;; Author: Nikolaj Schumacher
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
32 (defgroup company-ispell nil
33 "Completion backend using Ispell."
36 (defcustom company-ispell-dictionary nil
37 "Dictionary to use for `company-ispell'.
38 If nil, use `ispell-complete-word-dict'."
39 :type '(choice (const :tag "default (nil)" nil)
40 (file :tag "dictionary" t)))
42 (defvar company-ispell-available 'unknown)
44 (defun company-ispell-available ()
45 (when (eq company-ispell-available 'unknown)
48 (lookup-words "WHATEVER")
49 (setq company-ispell-available t))
51 (message "Company: ispell-look-command not found")
52 (setq company-ispell-available nil))))
53 company-ispell-available)
56 (defun company-ispell (command &optional arg &rest ignored)
57 "`company-mode' completion backend using Ispell."
58 (interactive (list 'interactive))
60 (interactive (company-begin-backend 'company-ispell))
61 (prefix (when (company-ispell-available)
64 (let ((words (lookup-words arg (or company-ispell-dictionary
65 ispell-complete-word-dict)))
66 (completion-ignore-case t))
68 ;; Small optimization.
70 ;; Work around issue #284.
71 (all-completions arg words))))
73 (ignore-case 'keep-prefix)))
75 (provide 'company-ispell)
76 ;;; company-ispell.el ends here