]> code.delx.au - gnu-emacs-elpa/blob - company-dabbrev.el
Added back-end file headers.
[gnu-emacs-elpa] / 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.
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 (defun company-dabbrev (command &optional arg &rest ignored)
33 (case command
34 ('prefix (company-grab-dabbrev-prefix))
35 ('candidates (let ((dabbrev-check-other-buffers))
36 (dabbrev--reset-global-variables)
37 (dabbrev--find-all-expansions arg t)))
38 ('ignore-case t)))
39
40 (provide 'company-dabbrev)
41 ;;; company-dabbrev.el ends here