-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcompany-term.el
48 lines (39 loc) · 1.26 KB
/
company-term.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
;;; company-term.el --- An company plug for multi-term -*- lexical-binding: t; -*-
;; Copyright (C) 2016 Aborn Jiang
;;; Code:
;;
;; TODO on development.
(require 'cl-lib)
(require 'company)
(defconst term-completions
'("ls" "cp" "mv" "rm" "ls -a" "df -h" "df" "ls -ltrh"))
(defun company-term--prefix ()
"Prefix-command handler for the company backend."
(and (eq major-mode 'term-mode)
(company-grab-symbol)))
(defun company-term--post-completion (candidate)
"Insert function arguments after completion for CANDIDATE."
;;(term-send-raw-string candidate)
;;(term-char-mode)
(message "%s" candidate))
(defun company-term (command &optional arg &rest ignored)
"company-term."
(interactive (list 'interactive))
(cl-case command
(interactive (company-begin-backend 'company-term))
(prefix (company-term--prefix))
;;(prefix (and (eq major-mode 'term-mode)
;;(company-grab-symbol)))
(candidates
(cl-remove-if-not
(lambda (c) (string-prefix-p arg c))
term-completions))
(meta (format "%s" arg))
(post-completion (company-term--post-completion arg))
))
;;;###autoload
(defun company-term-setup ()
"add to list"
(add-to-list 'company-backends 'company-term))
(provide 'company-term)
;;; company-term.el ends here