Klimi's new dotfiles with stow.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.2 KiB

4 years ago
  1. ;;; company-tempo.el --- company-mode completion backend for tempo
  2. ;; Copyright (C) 2009-2011, 2015 Free Software Foundation, Inc.
  3. ;; Author: Nikolaj Schumacher
  4. ;; This file is part of GNU Emacs.
  5. ;; GNU Emacs is free software: you can redistribute it and/or modify
  6. ;; it under the terms of the GNU General Public License as published by
  7. ;; the Free Software Foundation, either version 3 of the License, or
  8. ;; (at your option) any later version.
  9. ;; GNU Emacs is distributed in the hope that it will be useful,
  10. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ;; GNU General Public License for more details.
  13. ;; You should have received a copy of the GNU General Public License
  14. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  15. ;;; Commentary:
  16. ;;
  17. ;;; Code:
  18. (require 'company)
  19. (require 'cl-lib)
  20. (require 'tempo)
  21. (defgroup company-tempo nil
  22. "Tempo completion backend."
  23. :group 'company)
  24. (defcustom company-tempo-expand nil
  25. "Whether to expand a tempo tag after completion."
  26. :type '(choice (const :tag "Off" nil)
  27. (const :tag "On" t)))
  28. (defsubst company-tempo-lookup (match)
  29. (cdr (assoc match (tempo-build-collection))))
  30. (defun company-tempo-insert (match)
  31. "Replace MATCH with the expanded tempo template."
  32. (search-backward match)
  33. (goto-char (match-beginning 0))
  34. (replace-match "")
  35. (call-interactively (company-tempo-lookup match)))
  36. (defsubst company-tempo-meta (match)
  37. (let ((templ (company-tempo-lookup match))
  38. doc)
  39. (and templ
  40. (setq doc (documentation templ t))
  41. (car (split-string doc "\n" t)))))
  42. ;;;###autoload
  43. (defun company-tempo (command &optional arg &rest ignored)
  44. "`company-mode' completion backend for tempo."
  45. (interactive (list 'interactive))
  46. (cl-case command
  47. (interactive (company-begin-backend 'company-tempo))
  48. (prefix (or (car (tempo-find-match-string tempo-match-finder)) ""))
  49. (candidates (all-completions arg (tempo-build-collection)))
  50. (meta (company-tempo-meta arg))
  51. (post-completion (when company-tempo-expand (company-tempo-insert arg)))
  52. (sorted t)))
  53. (provide 'company-tempo)
  54. ;;; company-tempo.el ends here