1 ;;; company-tempo.el --- a company-mode completion back-end for tempo
3 ;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
5 ;; Author: Nikolaj Schumacher
7 ;; This file is part of GNU Emacs.
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.
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.
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/>.
25 (eval-when-compile (require 'cl))
28 (defsubst company-tempo-lookup (match)
29 (cdr (assoc match (tempo-build-collection))))
31 (defun company-tempo-insert (match)
32 "Replace MATCH with the expanded tempo template."
33 (search-backward match)
34 (goto-char (match-beginning 0))
36 (call-interactively (company-tempo-lookup match)))
38 (defsubst company-tempo-meta (match)
39 (let ((templ (company-tempo-lookup match))
42 (setq doc (documentation templ t))
43 (car (split-string doc "\n" t)))))
46 (defun company-tempo (command &optional arg &rest ignored)
47 "A `company-mode' completion back-end for tempo."
48 (interactive (list 'interactive))
50 ('interactive (company-begin-backend 'company-tempo
51 'company-tempo-insert))
52 ('prefix (or (car (tempo-find-match-string tempo-match-finder)) ""))
53 ('candidates (all-completions arg (tempo-build-collection)))
54 ('meta (company-tempo-meta arg))
58 (provide 'company-tempo)
59 ;;; company-tempo.el ends here