company-mode の backend を書く
一番シンプルなものはこういう感じになる.
(require 'cl-lib) (defvar company-example-source '("newton" "gauss" "euler" "cauchy")) (defun company-example (command &optional arg &rest ignored) (interactive (list 'interactive)) (cl-case command (interactive (company-begin-backend 'company-example)) (prefix (and (eq major-mode 'fundamental-mode) (company-grab-symbol))) (candidates (cl-remove-if-not (lambda (c) (string-prefix-p arg c)) company-example-source)))
適当な補完候補のリストを作ってやって company の backend の関数を書く. 関数名(company-example)と major-mode(fundamental-mode)は好みのものにすれば良い.
あとはバックエンドを追加してやればいい.
(add-to-list 'company-backends 'company-example)