有意隐藏了,避免输出大量信息,挤爆 *Messages*
(let (message-log-max)
(message "这条不会出现在 *Messages* 中")
nil)
1 个赞
多谢,感觉这个message-log-max
很好用。Info里也没有写它可以用来避免输出到*Message*
写了,C-h S 会优先查 Emacs 手册,但是 Emacs Lisp 手册里写了:
Here’s how to display a message and prevent it from being logged:
(let (message-log-max) (message …))
我没有设置, 刚好显示的是排序的, 不知道呢…
不过, 我设置的 对齐选项 company-tooltip-align-annotations
, 说明这是个 annotations
。
FYI, 我不知道该如何写,所以如果你写完的话,记得贴上来啊哈哈
猜测是补全后端直接提供的,和 company-mode 没啥关系
点击分享按钮,再点创建新主题,很容易的。
原来在elisp下面……涨姿势了
我写了个查文档的网站,里面有 info 链接,会优先考虑 elisp 的文档。在 Emacs 里的话,需要跑到 elisp 的 Index 里找。
本来还想问问, 能不能操作echo area里面的数据, 看来是不行了.
设置 set-message-function 和 clear-message-function
2 个赞
我通过参考https://emacs-china.org/t/tabnine/9988/40自己实现了一下,你可以稍微改改。
现在的效果是:前5个为company-tabnine按概率排序补全结果,后3个为company-ctags补全结果,最后2个为company-yasnippet补全结果。 现在有一个不足是:会忽略company-tabnine补全结果中detail值为空的项。
(defun company-tabnine-sort-by-detail (candidates)
"Sort tabnine response by detail value"
(sort candidates
(lambda (c1 c2)
(let ((d1 (get-text-property 0 'detail c1))
(d2 (get-text-property 0 'detail c2)))
;; 默认忽略type
(or d1 (setq d1 "1%"))
(or d2 (setq d2 "1%"))
(>= (string-to-number d1) (string-to-number d2))))))
(defun company-sort-by-tabnine-and-ctags (candidates)
"sort company backends response"
(when (or (functionp company-backend)
(not (and (listp company-backend)
(memq 'company-tabnine company-backend))))
candidates)
(let (candidates-tabnine candidates-ctags candidates-yas)
(setq candidates-max-length (min (length candidates) 20))
(dolist (candidate candidates)
(setq backend-property (get-text-property 0 'company-backend candidate))
(cond
((eq backend-property 'company-ctags)
(push candidate candidates-ctags))
((eq backend-property 'company-yasnippet)
(push candidate candidates-yas))
(t (push candidate candidates-tabnine))))
;; (setq candidates-tabnine (nreverse candidates-tabnine))
(setq candidates-tabnine (company-tabnine-sort-by-detail candidates-tabnine))
(setq candidates-ctags (nreverse candidates-ctags))
(setq candidates-yas (nreverse candidates-yas))
(setq candidates (nconc (seq-take candidates-tabnine 5)
(seq-take candidates-ctags 3)
(seq-take candidates-yas 2)))
(setq candidates-other (nconc (seq-drop candidates-tabnine 5)
(seq-drop candidates-ctags 3)
(seq-drop candidates-yas 2)))
(let ((len (length candidates)))
(when (< len candidates-max-length)
(setq candidates (nconc candidates (seq-take candidates-other (- candidates-max-length len))))))
candidates))
;; (add-to-list 'company-transformers 'company-sort-by-tabnine-and-ctags t)
;; (add-to-list 'company-backends '(company-tabnine :separate company-etags))
2 个赞