想调试一个elisp函数,按照elisp 说明文档在函数内容合适位置添加(debug) 并设置eval-defun, C-x C-e可以打开debug窗口,但Edebug如何启动呢? 尝试了edebug-mode,显示
edebug-eval-last-sexp: Symbol’s value as variable is void: edebug-outside-windows
如何进入edebug调试的模式呢?
想调试一个elisp函数,按照elisp 说明文档在函数内容合适位置添加(debug) 并设置eval-defun, C-x C-e可以打开debug窗口,但Edebug如何启动呢? 尝试了edebug-mode,显示
edebug-eval-last-sexp: Symbol’s value as variable is void: edebug-outside-windows
如何进入edebug调试的模式呢?
Emacs里面的Emacs Lisp Reference Manual里面有怎么用edebug的内容,你可以去看看
另外,edebug在指定你要调试的函数之后,直接执行该函数或者程序执行到了该函数就直接进入edebug了
C-u C-M-x
其中的 prefix arg 表示启用 edebug,比如:
(defun foo (a b)
(+ a b))
(foo 1 2)
这不是 edebug,而是 lisp debugger
感谢,我知道我自己的问题了, 我用的evil-mode,doom emacs快捷键被捆绑了,C-u 变成了查找 同时C-M-x 被有道词典取词截获 最后想问一下C-u C-M-x 对应绑定的函数是什么? 我试过eval-defun edebug-eval-defun都不对
为什么不 emacs -q
启动 vanilla emacs ,然后使用 C-h k 查找函数呢?
(edebug-eval-defun t)
C-M-x 是 eval-defun,C-u 设置 prefix arg,绑定 universal-argument 命令,整体相当于 C-u M-x eval-defun。
主要是对C-u的功能不太熟悉,我以为C-u C-M-x直接绑定了eval-defun,原来C-u 是传参数:
(universal-argument)
Begin a numeric argument for the following command.
Digits or minus sign following C-u make up the numeric argument.
C-u following the digits or minus sign ends the argument.
C-u without digits or minus sign provides 4 as argument.
Repeating C-u without digits or minus sign
multiplies the argument by 4 each time.
For some commands, just C-u by itself serves as a flag
which is different in effect from any particular numeric argument.
These commands include C-SPC and M-x start-kbd-macro.
eval-defun 说明:
With a prefix argument, instrument the code for Edebug.
If acting on a ‘defun’ for FUNCTION, and the function was
instrumented, ‘Edebug: FUNCTION’ is printed in the echo area. If not
instrumented, just FUNCTION is printed.
友情提示, 不用定义函数也能直接用 edebug 函数 edebug-defun
, 比如:
(let ((packages '(counsel
flycheck
format-all
ivy
neotree
use-package
yasnippet
yasnippet-snippets)))
(length packages)
(insert (s-join "\n"
(-map #'symbol-name
(-difference packages
package-selected-packages)))))