我写的项目可能比较low,基本上都是接口对应的实现类方法一一对应的,所以我希望能够直接跳转到实现类,并关闭 xref buffer,写了下面的代码。
(defun lucius/xref-show-xrefs (fetcher display-action)
"Display some Xref values produced by FETCHER using DISPLAY-ACTION.
After jumping to the first xref, close the xref window."
(let ((buf (xref--show-xref-buffer fetcher
`((window . ,(selected-window))
(display-action . ,display-action)
(auto-jump . t)))))
(when xref-auto-jump-to-first-xref
(let ((window (get-buffer-window buf)))
(when window
(quit-window nil window))))))
(setq xref-auto-jump-to-first-xref t)
(setq xref-show-xrefs-function #'lucius/xref-show-xrefs)