为什么 emacs 在 windows 下总是查找不到引用

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

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

为什么emacswindows下总是查找不到引用

最近迷上了emacsTAGS,因为它比使用clangd阅读源代码来得更快,可能还更准确。但是现实情况是cygwinTAGS用起来很好,windows上只能用M-.来查找定义,想要查找引用却始终失败。
在这里插入图片描述

Searching d:/demos/emacs-28.2/src/... done
xref--not-found-error: No references found for: stack_bottom
  1. 生成TAGS的方法是:在编译emacs完成后,顺便运行一下make TAGS即可。
  2. 我用到的edebug的一些快捷键:C-u C-M-x-设置edebugC-M-x-取消edebugSPC-单步步过,b-设置断点,i-步入,o-步出。
  3. 查找引用xref-find-referencesM-?)。
  4. xref里没有我所相像的peek,在查找到的结果窗口内按n或者p可以直接跳转而不会失去焦点。
  5. edebug中想要查看某变量的值,将光标移到它的结尾,按C-x C-e
  6. edebug上执行C-x C-e出现Debugger entered--Lisp error: (void-variable cmd)时,不要按q,这会导致整个edebug退出,而要按c让它继续。
  7. 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-di
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值