]> code.delx.au - gnu-emacs-elpa/blob - company-tempo.el
Fix a test (after adding `should`)
[gnu-emacs-elpa] / company-tempo.el
1 ;;; company-tempo.el --- company-mode completion backend for tempo
2
3 ;; Copyright (C) 2009-2011, 2015 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
23 ;;; Commentary:
24 ;;
25
26 ;;; Code:
27
28 (require 'company)
29 (require 'cl-lib)
30 (require 'tempo)
31
32 (defsubst company-tempo-lookup (match)
33 (cdr (assoc match (tempo-build-collection))))
34
35 (defun company-tempo-insert (match)
36 "Replace MATCH with the expanded tempo template."
37 (search-backward match)
38 (goto-char (match-beginning 0))
39 (replace-match "")
40 (call-interactively (company-tempo-lookup match)))
41
42 (defsubst company-tempo-meta (match)
43 (let ((templ (company-tempo-lookup match))
44 doc)
45 (and templ
46 (setq doc (documentation templ t))
47 (car (split-string doc "\n" t)))))
48
49 ;;;###autoload
50 (defun company-tempo (command &optional arg &rest ignored)
51 "`company-mode' completion backend for tempo."
52 (interactive (list 'interactive))
53 (cl-case command
54 (interactive (company-begin-backend 'company-tempo
55 'company-tempo-insert))
56 (prefix (or (car (tempo-find-match-string tempo-match-finder)) ""))
57 (candidates (all-completions arg (tempo-build-collection)))
58 (meta (company-tempo-meta arg))
59 (sorted t)))
60
61 (provide 'company-tempo)
62 ;;; company-tempo.el ends here