关掉 copilot.el 的警告⚠️

copilot.el 是一个很好用的包,但是当 buffer 太大时它会弹出一个 warning 窗口,这有点烦,所以我用了一个 advice 来把 warn 改为 message:

(defadvice! +copilot--get-source-a (fn &rest args)
    :around #'copilot--get-source
    (cl-letf (((symbol-function #'warn) #'message))
      (apply fn args)))

defadvice! 是从 doom 抄来的一个很好用的宏:

(defmacro defadvice! (symbol arglist &rest body)
  "Define an advice called SYMBOL and add it to PLACES.

ARGLIST is as in `defun'. WHERE is a keyword as passed to `advice-add', and
PLACE is the function to which to add the advice, like in `advice-add'.
DOCSTRING and BODY are as in `defun'.

\(fn SYMBOL ARGLIST &rest [WHERE PLACES...] BODY\)"
  (declare (indent defun))
  (let (where-alist)
    (while (keywordp (car body))
      (push `(cons ,(pop body) (ensure-list ,(pop body)))
            where-alist))
    `(progn
       (defun ,symbol ,arglist ,@body)
       (dolist (targets (list ,@(nreverse where-alist)))
         (dolist (target (cdr targets))
           (advice-add target (car targets) #',symbol))))))
6 个赞

这个warn确实挺烦人的 还是前阵子的PR

不过大文件的处理我之前提过一个PR 来根据copilot-max-char限制传输到server的内容避免copilot json处理的卡顿,他可能发现这样的操作会让copilot补全出问题 :rofl:

1 个赞

刚刚点了 merge,之前把这个 PR 忘了。 另外 copilot.el 需要新的 maintainer,我目前因为不用 Emacs 了也就没法维护了。

3 个赞