]> code.delx.au - gnu-emacs-elpa/blob - packages/company-0.5/company-ispell.el
0b83515336ff9ac64cec5f4353e3c740e2a53ace
[gnu-emacs-elpa] / packages / company-0.5 / company-ispell.el
1 ;;; company-ispell.el --- a company-mode completion back-end using ispell
2
3 ;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
4
5 ;; Author: Nikolaj Schumacher
6
7 ;; This file is part of GNU Emacs.
8
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.
13
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.
18
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/>.
21
22 ;;; Code:
23
24 (require 'company)
25 (require 'ispell)
26 (eval-when-compile (require 'cl))
27
28 (defcustom company-ispell-dictionary nil
29 "*Dictionary to use for `company-ispell'.
30 If nil, use `ispell-complete-word-dict'."
31 :group 'company
32 :type '(choice (const :tag "default (nil)" nil)
33 (file :tag "dictionary" t)))
34
35 (defvar company-ispell-available 'unknown)
36
37 (defun company-ispell-available ()
38 (when (eq company-ispell-available 'unknown)
39 (condition-case err
40 (progn
41 (lookup-words "WHATEVER")
42 (setq company-ispell-available t))
43 (error
44 (message "Company: ispell-look-command not found")
45 (setq company-ispell-available nil))))
46 company-ispell-available)
47
48 ;;;###autoload
49 (defun company-ispell (command &optional arg &rest ignored)
50 "A `company-mode' completion back-end using ispell."
51 (interactive (list 'interactive))
52 (case command
53 ('interactive (company-begin-backend 'company-ispell))
54 ('prefix (when (company-ispell-available)
55 (company-grab-word)))
56 ('candidates (lookup-words arg (or company-ispell-dictionary
57 ispell-complete-word-dict)))
58 ('sorted t)
59 ('ignore-case t)))
60
61 (provide 'company-ispell)
62 ;;; company-ispell.el ends here