-
Notifications
You must be signed in to change notification settings - Fork 0
/
company-gemoji.el
59 lines (44 loc) · 1.78 KB
/
company-gemoji.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
;;; company-gemoji.el --- summary -*- lexical-binding: t -*-
;; Author: takeo obara
;; Maintainer: takeo obara
;; Version: 1.0.0
;; Package-Requires: (company)
;; Homepage: https://github.com/takeokunn/company-gemoji
;; Keywords: company
;; This file is not part of GNU Emacs
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; For a full copy of the GNU General Public License
;; see <http://www.gnu.org/licenses/>.
(require 'cl-lib)
(require 'company)
(require 'text-mode)
(require 'company-gemoji-data)
(defcustom company-gemoji-self-keywords '()
"If you want to add emoji, you should add to `company-gemoji-self-keywords`"
:type '(alist string))
(defvar company-gemoji--keywords
(cl-concatenate 'list company-gemoji-data-keywords company-gemoji-self-keywords))
(defun company-gemoji--candidates (prefix)
(let (res)
(message prefix)
(dolist (item company-gemoji--keywords)
(when (string-prefix-p prefix item)
(push item res)))
res))
(defun company-gemoji (command &optional arg &rest ignored)
"Gemoji backend for company mode."
(interactive (list 'interactive))
(cl-case command
(interactive (company-begin-backend 'company-gemoji))
(prefix (when (eq major-mode 'text-mode)
(company-grab-symbol)))
(candidates (company-gemoji--candidates arg))))
(provide 'company-gemoji)
;;; company-gemoji.el ends here