错误的参数类型:数字或标记。

7
这是Emacs在抱怨什么。我偶尔会遇到这个错误,但我刚刚接触Emacs世界,对C也不是很熟悉。现在,Emacs阻止我继续编码,甚至不让我打开括号?这个错误是什么意思?
编辑: 我的Emacs版本:
我的调试信息:
Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p (1953 . 3706))
  c-looking-at-inexpr-block((1953 . 3706) (1953 . 3706))
  c-inside-bracelist-p(3742 ((1953 . 3706) (1953 . 3706) 3742 (1953 . 3706) 3742 (1953 . 3706) 3742 (1953 . 3706) 9156 (9046 . 9137) 3742 (1953 . 3706) 9156 (9046 . 9137) 3742 (1953 . 3706) 9156 (9046 . 9137) 3742 (1953 . 3706) 9156 (9046 . 9137) 3742 (1953 . 3706) 9156 (9046 . 9137) 3742 (1953 . 3706) 3742 (1953 . 3706) 3742 (1953 . 3706) 3742 (1953 . 3706) 3742 (1953 . 3706) 3742 (1953 . 3706) 3742 (1953 . 3706) 3742 (1953 . 3706) 3742 (1953 . 3706) 3742 (1953 . 3706) 3742 (1953 . 3706) 3742 (1953 . 3706) ...))
  c-guess-basic-syntax()
  c-indent-line()
  indent-according-to-mode()
  c-electric-continued-statement()
  abbrev-insert(while #("while" 0 5 (fontified t face font-lock-keyword-face)) 9785 9790)
  #[0 "\304 \211@A\211@A\211@A\211@A\n\211\205Q\305`\306\"\305\306\"\2042\307\310 !\2042\311 \210\312   $V\203O`U\203Ob\210\266\202\266\204\207" [noninteractive last-abbrev-text last-abbrev last-abbrev-location abbrev--before-point copy-marker t window-minibuffer-p selected-window undo-boundary abbrev-insert] 20 "\n\n(fn)"]()
  apply(#[0 "\304 \211@A\211@A\211@A\211@A\n\211\205Q\305`\306\"\305\306\"\2042\307\310 !\2042\311 \210\312 $V\203O`U\203Ob\210\266\202\266\204\207" [noninteractive last-abbrev-text last-abbrev last-abbrev-location abbrev--before-point copy-marker t window-minibuffer-p selected-window undo-boundary abbrev-insert] 20 "\n\n(fn)"] nil)
  #[771 ":\2030@\301=\203\300@\302A\"\303#\207\304@\305\306\307\310\311\312\300!\313\"\314\315%A##\207\304\316\"\207" [(#0) t append nil apply apply-partially make-byte-code 642 "\300@#\207" vconcat vector [] 7 "\n\n(fn FUNS GLOBAL &rest ARGS)" #[0 "\304 \211@A\211@A\211@A\211@A\n\211\205Q\305`\306\"\305\306\"\2042\307\310 !\2042\311 \210\312    $V\203O`U\203Ob\210\266\202\266\204\207" [noninteractive last-abbrev-text last-abbrev last-abbrev-location abbrev--before-point copy-marker t window-minibuffer-p selected-window undo-boundary abbrev-insert] 20 "\n\n(fn)"]] 12 "\n\n(fn FUNS GLOBAL ARGS)"](nil nil nil)
  expand-abbrev()
  self-insert-command(1)
  c-electric-paren(nil)
  call-interactively(c-electric-paren nil nil)

我对这段代码不熟悉,所以可能会漏掉一些东西,但在我看来,这似乎是c-inside-bracelist-p中的一个错误,或者生成了无效的paren-stateparen-state元素可以是cons单元格,虽然其中一些代码已经考虑到了这一点,但是调用c-looking-at-inexpr-block的参数仅为(car paren-state),这可能不是整数,但随后被用作整数(因此出现错误)。我不知道在paren-state中连续有两个cons单元格是否有效,但这就是导致错误的情况。 - phils
2
如果你找不到相关的错误报告,我认为你应该执行 M-x report-emacs-bug - phils
1
如果您想要解决这个问题,第一步是设置一个最小可重现的示例。请提供Emacs版本、C测试文件和最小化配置(建议使用emacs -q)。发布图片很少有帮助。 - abo-abo
Emacs 版本 24.3.1。我能够复制错误,事实上我无法解决它。然而,我缩进了整个缓冲区,目前没有更多错误了。当它再次出现时,我将尝试使用 emacs -Q。 - mimoralea
@abo-abo同意,如果我知道如何复制它的话。如果你读了我的问题,我想知道的是什么意思?有什么问题。 - mimoralea
显示剩余3条评论
1个回答

4
你可以使用Lisp调试器更精确地了解正在发生的事情。
  1. 加载源(而不是字节编译)文件cc-cmds.el(定义了c-indent-line)和cc-engine.el(定义了c-guess-basic-syntaxc-inside-bracelist-pc-looking-at-inexpr-block)。

    (使用M-x load-library cc-cmds.elM-x load-library cc-engine.el - 不要忘记.el。)

  2. 在单独的框架中打开这两个源文件(C-x 5 f),并导航到您将使用调试器跟踪的函数。这样,您就可以更轻松地看到调试器正在执行的上下文。

  3. 然后运行M-x debug-on-entry c-indent-line

    使用d逐步进行调试。您可以使用c跳过任何您不想深入了解的步骤。

你也可以从M-x debug-on-entry c-looking-at-inexpr-block等开始,但那可能无法为你提供足够的上下文来查看发生了什么。您还可以开始时大量使用c而不是d,以快速确定要放慢速度并查看详细信息的位置。也就是说,多次运行调试器来引发错误,使用二分查找缩小您想要关注详细信息的范围(使用d)。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接