另外,关于和其他 capf 后端联合使用的问题,这个要求 capf 后端是 “non-exclusive” 的,但 Emacs 目前对这个的支持有 bug,见 completion--capf-wrapper
中的注释:
;; FIXME: Here we'd need to decide whether there are valid completions against
;; the current text. But this depends on the actual completion UI (e.g. with
;; the default completion it depends on completion-style) ;-( We approximate
;; this result by checking whether prefix completion might work, which means
;; that non-prefix completion will not work (or not right) for completion
;; functions that are non-exclusive.
因为 Citre 支持 substring completion(见 citre-capf-substr-completion
),这个 bug 会影响 Citre,所以 Citre 的 capf 后端做成 exclusive 的了,也就是说如果 Citre 提供了结果,Emacs 就不会继续问后续的补全后端要结果。
但是 Corfu 有一个 advice 修了这个问题,见 corfu-mode
的注释:
;; FIXME: Install advice which fixes `completion--capf-wrapper', such that it
;; respects the completion styles for non-exclusive capfs. See FIXME in the
;; `completion--capf-wrapper' function in minibuffer.el, where the issue has
;; been mentioned. We never uninstall this advice since the advice is active
;; *globally*.
所以如果把 Citre 的后端做成 non-exclusive 的(很简单,一行代码的事),在 corfu 里是可以正常使用的,但我需要评估一下要不要这么修,毕竟也有很多用户不用 corfu 的。
一个简单的做法是把 citre-completion-at-point
放在 completion-at-point-functions
里面其他 non-exclusive 后端的后面,这样就不影响了。我看了下 cape 里面大多数或者全部后端应该都是 non-exclusive 的。
顺便其实我之前也交过一个补丁修正这个问题(https://debbugs.gnu.org/cgi/bugreport.cgi?bug=39600),和 corfu 做的事情差不多,不过维护者觉得这个修法不对