开发者

What does it mean when emacs tells me "File mode specification error"?

开发者 https://www.devze.com 2023-01-25 15:48 出处:网络
This开发者_运维知识库 is the most useless error message I have ever seen. I think it translates to .. \"error\".

This开发者_运维知识库 is the most useless error message I have ever seen.

I think it translates to .. "error".

The full error message from the *Messages* buffer is:

File mode specification error: (wrong-type-argument characterp "string value here")

I think the latter part of that message means that emacs was expecting a character and got a string.

But how do I go about diagnosing just what it means when emacs tells me "File mode specification error" ? and how do I narrow down where this error is originating?

How are these two errors (file mode error, expecting character and got string) related?


Use M-x toggle-debug-on-error RET to drop into the debugger when this (or any) error occurs -- assuming that this is a proper error, and not just a message. That gives you the stack trace, so you can figure out what caused it, and proceed from there (possibly with edebug, once you've determined which function(s) to instrument, but you can do plenty with the regular debugger).

Standard debugger commands: M-: (info "(elisp) Debugger Commands") RET

Main manual entry for debugging lisp (including edebug): M-: (info "(elisp) Debugging") RET

FYI, rgrep tells me that the only instance of the string "File mode specification error" in the *.el files for NTEmacs 23.2.1 appears in the normal-mode function definition:
M-x find-function RET normal-mode RET


You might want to say what version of Emacs you are using.

If it's GNU Emacs 23, then the relevant code is in the function normal-mode in files.el and looks like this:

(report-errors "File mode specification error: %s"
  (set-auto-mode))

So the function set-auto-mode (or some function called from there) is signalling the wrong-type-argument error and normal-mode is adding the text File mode specification error in an attempt to help you track it down, but sadly it's not helping here, because the function of set-auto-mode is to determine which major mode a buffer should have, and then turn on that mode. I expect it's the mode itself that's signalling the error.

So phils' advice to turn on debug-on-error and look at the backtrace is a good one: that should give you a clue as to what's going on.


For me, it happened because I had an extra pair of () parenthesis around a function body I wrote. I guess that makes lisp attempt to execute the return value of the function body. So pay attention to your parenthesis count!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号