]> rtime.felk.cvut.cz Git - sojka/company-mode.git/blob - company-dabbrev.el
Bumped version to 0.3.1.
[sojka/company-mode.git] / company-dabbrev.el
1 ;;; company-dabbrev.el --- a company-mode completion back-end for dabbrev
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 'dabbrev)
22 (eval-when-compile (require 'cl))
23
24 (defun company-grab-dabbrev-prefix ()
25   (save-excursion
26     (when (looking-at "\\>")
27       (let ((end (point)))
28         (dabbrev--reset-global-variables)
29         (dabbrev--goto-start-of-abbrev)
30         (buffer-substring-no-properties (point) end)))))
31
32 ;;;###autoload
33 (defun company-dabbrev (command &optional arg &rest ignored)
34   "A `company-mode' completion back-end for `dabbrev-completion'."
35   (interactive (list 'interactive))
36   (case command
37     ('interactive (company-begin-backend 'company-dabbrev))
38     ('prefix (company-grab-dabbrev-prefix))
39     ('candidates (let ((dabbrev-check-other-buffers))
40                    (dabbrev--reset-global-variables)
41                    (dabbrev--find-all-expansions arg t)))
42     ('ignore-case t)))
43
44 (provide 'company-dabbrev)
45 ;;; company-dabbrev.el ends here