使用与lsp结合的代码时报错了
| emacs-version | 27.2 |
| citre | 20210924.1215 |
| xref | 1.2.2 |
||emacs-version|27.2| |ss|sss|
backtrace
Debugger entered--Lisp error: (void-variable fetcher)
(funcall fetcher)
(condition-case err (funcall fetcher) ((debug error) (message "%s, fallback to citre" err) nil))
(or (condition-case err (funcall fetcher) ((debug error) (message "%s, fallback to citre" err) nil)) (funcall citre-fetcher))
(lambda nil (or (condition-case err (funcall fetcher) ((debug error) (message "%s, fallback to citre" err) nil)) (funcall citre-fetcher)))()
xref--show-defs-buffer((lambda nil (or (condition-case err (funcall fetcher) ((debug error) (message "%s, fallback to citre" err) nil)) (funcall citre-fetcher))) ((window . #<window 3 on main.c>) (display-action)))
xref--show-defs((lambda nil (or (condition-case err (funcall fetcher) ((debug error) (message "%s, fallback to citre" err) nil)) (funcall citre-fetcher))) nil)
xref--find-definitions(#("cache_op_inner" 0 14 (citre-xref-get-at-point t citre-tags-file "/home/schspa/.cache/tags/!mnt!work!src!optee_os!.t..." citre-file-path "/mnt/work/src/optee_os/core/arch/arm/plat-ti/main...." citre-syntax function citre-bounds (2349 . 2363))) nil)
xref-find-definitions(#("cache_op_inner" 0 14 (citre-xref-get-at-point t citre-tags-file "/home/schspa/.cache/tags/!mnt!work!src!optee_os!.t..." citre-file-path "/mnt/work/src/optee_os/core/arch/arm/plat-ti/main...." citre-syntax function citre-bounds (2349 . 2363))))
funcall-interactively(xref-find-definitions #("cache_op_inner" 0 14 (citre-xref-get-at-point t citre-tags-file "/home/schspa/.cache/tags/!mnt!work!src!optee_os!.t..." citre-file-path "/mnt/work/src/optee_os/core/arch/arm/plat-ti/main...." citre-syntax function citre-bounds (2349 . 2363))))
call-interactively(xref-find-definitions nil nil)
command-execute(xref-find-definitions)
自己加的debutlog打印
citre-fetcher = #[0 "\212\307\303!\203\0\303q\210\3101\0\304b0\202\0\210\202\0\210\306\305\302\"\211\204&\0\311\301\300\"\210\211\262)\207" [#("cache_op_inner" 0 14 (citre-bounds (2349 . 2363) citre-syntax function citre-file-path "/mnt/work/src/optee_os/core/arch/arm/plat-ti/main.c" citre-tags-file "/home/schspa/.cache/tags/!mnt!work!src!optee_os!.tags" citre-xref-get-at-point t)) definitions #("cache_op_inner" 0 14 (citre-bounds (2349 . 2363) citre-syntax function citre-file-path "/mnt/work/src/optee_os/core/arch/arm/plat-ti/main.c" citre-tags-file "/home/schspa/.cache/tags/!mnt!work!src!optee_os!.tags" citre-xref-get-at-point t)) #<buffer main.c> 2351 citre xref-backend-definitions buffer-live-p (error) xref--not-found-error] 4]
fetcher = #[0 "\212\307\303!\203\0\303q\210\3101\0\304b0\202\0\210\202\0\210\306\305\302\"\211\204&\0\311\301\300\"\210\211\262)\207" [#("cache_op_inner" 0 14 (citre-bounds (2349 . 2363) citre-syntax function citre-file-path "/mnt/work/src/optee_os/core/arch/arm/plat-ti/main.c" citre-tags-file "/home/schspa/.cache/tags/!mnt!work!src!optee_os!.tags" citre-xref-get-at-point t)) definitions #("cache_op_inner" 0 14 (citre-bounds (2349 . 2363) citre-syntax function citre-file-path "/mnt/work/src/optee_os/core/arch/arm/plat-ti/main.c" citre-tags-file "/home/schspa/.cache/tags/!mnt!work!src!optee_os!.tags" citre-xref-get-at-point t)) #<buffer main.c> 2351 citre xref-backend-definitions buffer-live-p (error) xref--not-found-error] 4]
Entering debugger...
funcall-interactively: Buffer is read-only: #<buffer *Messages*> [2 times]
配置代码, 从 .emacs.d/init-ctags.el at master · seagle0128/.emacs.d · GitHub 抄来的
;; Ctags IDE on the True Editor
;; @see https://github.com/universal-ctags/citre#quick-start
(when emacs/>=26p
(use-package citre
:diminish
:bind (("C-x c j" . citre-jump+)
("C-x c k" . citre-jump-back)
("C-x c p" . citre-peek)
("C-x c a" . citre-ace-peek)
("C-x c u" . citre-update-this-tags-file))
:init
(require 'citre-config)
(setq citre-auto-enable-citre-mode-modes '(prog-mode))
(defun citre-jump+ ()
"Jump to the definition of the symbol at point.
Fallback to `xref-find-definitions'."
(interactive)
(condition-case _
(citre-jump)
(error (call-interactively #'xref-find-definitions))))
:config
(with-no-warnings
(with-eval-after-load 'projectile
(setq citre-project-root-function #'projectile-project-root))
;; Integrate with `lsp-mode' and `eglot'
(define-advice xref--create-fetcher (:around (fn &rest args) fallback)
(let ((fetcher (apply fn args))
(citre-fetcher
(let ((xref-backend-functions '(citre-xref-backend t)))
(ignore xref-backend-functions)
(apply fn args))))
(message "citre-fetcher = %S" citre-fetcher)
(message "fetcher = %S" fetcher)
(lambda ()
(or (with-demoted-errors "%s, fallback to citre"
(funcall fetcher))
(funcall citre-fetcher)))))
(defun lsp-citre-capf-function ()
"A capf backend that tries lsp first, then Citre."
(let ((lsp-result (pcase centaur-lsp
('lsp-mode
(and (fboundp #'lsp-completion-at-point)
(lsp-completion-at-point)))
('eglot
(and (fboundp #'eglot-completion-at-point)
(eglot-completion-at-point))))))
(if (and lsp-result
(try-completion
(buffer-substring (nth 0 lsp-result)
(nth 1 lsp-result))
(nth 2 lsp-result)))
lsp-result
(citre-completion-at-point))))
(defun enable-lsp-citre-capf-backend ()
"Enable the lsp + Citre capf backend in current buffer."
(add-hook 'completion-at-point-functions #'lsp-citre-capf-function nil t))
(add-hook 'citre-mode-hook #'enable-lsp-citre-capf-backend))))