]> rtime.felk.cvut.cz Git - sojka/company-mode.git/blob - company-ispell.el
Added version number to back-ends.
[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.2.
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 (defun company-ispell (command &optional arg &rest ignored)
45   "A `company-mode' completion back-end using ispell."
46   (case command
47     ('prefix (when (company-ispell-available)
48                (company-grab "\\<\\w+\\>")))
49     ('candidates (lookup-words arg (or company-ispell-dictionary
50                                        ispell-complete-word-dict)))
51     ('sorted t)
52     ('ignore-case t)))
53
54 (provide 'company-ispell)
55 ;;; company-ispell.el ends here