官方文档有 debug-on-message 的介绍,为啥我找不到?
不要用 set-variable
,用 describe-variable
:
$ emacs -Q --eval "(describe-variable 'debug-on-message)"
我直接 M-x describe-variable 然后输入 debug-on-message 是可以找到的,但难道我不是要设置这个变量的值以便出现匹配消息后进入调试模式吗? 如何设置呢?
以下是设置变量的方法:
(setq debug-on-error t)
以下是为什么有的变量在 set-variable
看不到原因:
↓
- set-variable
- read-variable
↓
M-x describe-function RET read-variable
↓
read-variable is a built-in function in ‘src/minibuf.c’. (read-variable PROMPT &optional DEFAULT-VALUE) Read the name of a user option and return it as a symbol. Prompt with PROMPT. By default, return DEFAULT-VALUE or its first element if it is a list of strings. A user option, or customizable variable, is one for which ‘custom-variable-p’ returns non-nil. ^^^^^^^^^^^^^^^^^ Probably introduced at or before Emacs version 17. [back]
↓
(custom-variable-p 'debug-on-event) ;; => ('sigusr2) ==> t
(custom-variable-p 'debug-on-error) ;; => (nil) ==> t
(custom-variable-p 'debug-on-message) ;; => nil
这个啥意思?我在哪里输入吗?
你后面部分是不是说因为 (custom-variable-p 'debug-on-message) ;; => nil
所以我实际上没法改这个变量值?
这样表示调用关系。
感情下面这段摘自 Error Debugging (GNU Emacs Lisp Reference Manual) 的是忽悠啊?
Variable: debug-on-message ¶
If you set debug-on-message
to a regular expression, Emacs will enter the debugger if it displays a matching message in the echo area. For example, this can be useful when trying to find the cause of a particular message.
没有人忽悠你,是你不认真看。set-variable
只能用于 custom 类的变量。
好吧,我问题描述不准确,我的问题是如何设置 debug-on-message to a regular expression
你是不知道有 setq
函数,还是不知道 Emacs 正则怎么写?
(setq 变量 值)
我不知道这里要用 setq 函数。
虽然貌似在init 文件里见过,但在 M-x 下,输入 setq 是没结果的, set 开头的就找到了 set-variable, 字面意义上看着像,于是就有了这个帖子
我试下setq 先
M-x
只能看到 interactive 类的函数。更多应该用 M-x describe-function
。
多谢!
如上图,我不确信这个 backtrace 显示出来是不是因为 debug-on-message 的设置起作用了。
但是当我在 Helm candidate 的窗口里按 C-x 0 后,如同以前,会闪现下面提示
Attempt to delete minibuffer or sole ordinary window
这个文字是不是也匹配 “*sole*
” ? 但没有backtrace 弹出来。
我一开始就是对这个出错消息好奇才想着尝试 debug-on-message 的。
说实话,正则这块,我也拿不准, 找了个线上正则工具试了下 sole* 可以匹配那个出错消息, *sole*
不行, 但结果还是如下图一样: