forked from radian-software/prescient.el
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompany-prescient.el
61 lines (45 loc) · 1.94 KB
/
company-prescient.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
;;; company-prescient.el --- prescient.el + Company -*- lexical-binding: t -*-
;; Copyright (C) 2018 Radon Rosborough
;; Author: Radon Rosborough <[email protected]>
;; Homepage: https://github.com/raxod502/prescient.el
;; Keywords: extensions
;; Created: 7 Aug 2017
;; Package-Requires: ((emacs "25.1") (prescient "2.2") (company "0.9.6"))
;; Version: 2.2
;;; Commentary:
;; company-prescient.el provides an interface for using prescient.el
;; to sort Company completions. To enable its functionality, turn on
;; `company-prescient-mode' in your init-file or interactively.
;; Note that company-prescient.el does not change the filtering
;; behavior of Company. This is because that can't be done without
;; updating each Company backend individually.
;; For more information, see https://github.com/raxod502/prescient.el.
;;; Code:
;;;; Libraries
(require 'company)
(require 'prescient)
(defalias 'company-prescient-transformer #'prescient-sort
"Candidate transformer function that uses prescient.el to sort candidates.
This is for use in `company-transformers'.")
(defalias 'company-prescient-completion-finished #'prescient-remember
"Hook function to remember selected Company candidate.
This is for use on `company-completion-finished-hook'.")
;;;###autoload
(define-minor-mode company-prescient-mode
"Minor mode to use prescient.el in Company completions."
:global t
(if company-prescient-mode
(progn
(add-to-list 'company-transformers #'company-prescient-transformer)
(add-hook 'company-completion-finished-hook
#'company-prescient-completion-finished))
(setq company-transformers
(delq #'company-prescient-transformer company-transformers))
(remove-hook 'company-completion-finished-hook
#'company-prescient-completion-finished)))
;;;; Closing remarks
(provide 'company-prescient)
;;; company-prescient.el ends here
;; Local Variables:
;; outline-regexp: ";;;;* "
;; End: