为什么emacs在windows下总是查找不到引用
最近迷上了emacs的TAGS,因为它比使用clangd阅读源代码来得更快,可能还更准确。但是现实情况是cygwin上TAGS用起来很好,windows上只能用M-.来查找定义,想要查找引用却始终失败。

Searching d:/demos/emacs-28.2/src/... done
xref--not-found-error: No references found for: stack_bottom
- 生成
TAGS的方法是:在编译emacs完成后,顺便运行一下make TAGS即可。 - 我用到的
edebug的一些快捷键:C-u C-M-x-设置edebug,C-M-x-取消edebug,SPC-单步步过,b-设置断点,i-步入,o-步出。 - 查找引用
xref-find-references(M-?)。 xref里没有我所相像的peek,在查找到的结果窗口内按n或者p可以直接跳转而不会失去焦点。- 在
edebug中想要查看某变量的值,将光标移到它的结尾,按C-x C-e。 - 当
edebug上执行C-x C-e出现Debugger entered--Lisp error: (void-variable cmd)时,不要按q,这会导致整个edebug退出,而要按c让它继续。 - 当
edebug上执行C-x C-e出现省略号时,如下,按M-:运行(setq edebug-print-length 200)。
"find -H d:/demos/emacs-28.2/src -type f \"-name\" \"..."
在xref-find-references处启动edebug,经过一堆无聊的步入步出操作后,最终定位了关键函数xref-references-in-directory:
;;;###autoload
(defun xref-references-in-directory (symbol dir)
"Find all references to SYMBOL in directory DIR.
Return a list of xref values.
This function uses the Semantic Symbol Reference API, see
`semantic-symref-tool-alist' for details on which tools are used,
and when."
(cl-assert (directory-name-p dir))
(require 'semantic/symref)
(defvar semantic-symref-tool)
;; Some symref backends use `ede-project-root-directory' as the root
;; directory for the search, rather than `default-directory'. Since
;; the caller has specified `dir', we bind `ede-minor-mode' to nil
;; to force the backend to use `default-directory'.
(let* ((ede-minor-mode nil)
(default-directory dir)
;; FIXME: Rem

本文讲述了作者在Windows环境下使用Emacs的TAGS功能遇到问题,尤其是在查找引用时失败。通过调试和代码分析,发现是由于find命令的路径问题,最后通过修改grep-find-template变量解决了问题。
最低0.47元/天 解锁文章
667

被折叠的 条评论
为什么被折叠?



