]> rtime.felk.cvut.cz Git - sojka/company-mode.git/blob - company-ispell.el
Bumped version to 0.3.1.
[sojka/company-mode.git] / company-ispell.el
1 ;;; company-ispell.el --- a company-mode completion back-end using ispell
2 ;;
3 ;; Copyright (C) 2009 Nikolaj Schumacher
4 ;;
5 ;; This file is part of company 0.3.1.
6 ;;
7 ;; This program is free software; you can redistribute it and/or
8 ;; modify it under the terms of the GNU General Public License
9 ;; as published by the Free Software Foundation; either version 2
10 ;; of the License, or (at your option) any later version.
11 ;;
12 ;; This program is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 ;; GNU General Public License for more details.
16 ;;
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
20 (require 'company)
21 (require 'ispell)
22 (eval-when-compile (require 'cl))
23
24 (defcustom company-ispell-dictionary nil
25   "*Dictionary to use for `company-ispell'.
26 If nil, use `ispell-complete-word-dict'."
27   :group 'company
28   :type '(choice (const :tag "default (nil)" nil)
29                  (file :tag "dictionary" t)))
30
31 (defvar company-ispell-available 'unknown)
32
33 (defun company-ispell-available ()
34   (when (eq company-ispell-available 'unknown)
35     (condition-case err
36         (progn
37           (lookup-words "WHATEVER")
38           (setq company-ispell-available t))
39       (error
40        (message "Company: ispell-look-command not found")
41        (setq company-ispell-available nil))))
42   company-ispell-available)
43
44 ;;;###autoload
45 (defun company-ispell (command &optional arg &rest ignored)
46   "A `company-mode' completion back-end using ispell."
47   (interactive (list 'interactive))
48   (case command
49     ('interactive (company-begin-backend 'company-ispell))
50     ('prefix (when (company-ispell-available)
51                (company-grab-word)))
52     ('candidates (lookup-words arg (or company-ispell-dictionary
53                                        ispell-complete-word-dict)))
54     ('sorted t)
55     ('ignore-case t)))
56
57 (provide 'company-ispell)
58 ;;; company-ispell.el ends here