]> code.delx.au - gnu-emacs-elpa/blob - company-0.5/company-abbrev.el
Initial repository contents
[gnu-emacs-elpa] / company-0.5 / company-abbrev.el
1 ;;; company-abbrev.el --- a company-mode completion back-end for abbrev
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 (eval-when-compile (require 'cl))
26 (require 'abbrev)
27
28 (defun company-abbrev-insert (match)
29 "Replace MATCH with the expanded abbrev."
30 (expand-abbrev))
31
32 ;;;###autoload
33 (defun company-abbrev (command &optional arg &rest ignored)
34 "A `company-mode' completion back-end for abbrev."
35 (interactive (list 'interactive))
36 (case command
37 ('interactive (company-begin-backend 'company-abbrev
38 'company-abbrev-insert))
39 ('prefix (company-grab-symbol))
40 ('candidates (nconc
41 (delete "" (all-completions arg global-abbrev-table))
42 (delete "" (all-completions arg local-abbrev-table))))
43 ('meta (abbrev-expansion arg))
44 ('require-match t)))
45
46 (provide 'company-abbrev)
47 ;;; company-abbrev.el ends here