为什么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-di