首页 > 解决方案 > 尽管安装了 sml-mode,但 Emacs 无法识别 SML 语法

问题描述

我已经在 Emacs(版本 26.2)中安装了包sml-mode(版本 6.9),但是当我尝试打开一个 .sml 文件时,我在 minibuffer 中收到以下错误:File mode specification error: (invalid-read-syntax ?). 因此,编辑器无法识别 SML 语法,这一点也很明显,因为当前模式显示的Fundamental模式不是SML.

这些是我设置环境的步骤:

使用 Mx toggle-debug-on-error 提供以下堆栈跟踪:

Debugger entered--Lisp error: (invalid-read-syntax "?")
read(#<buffer  *load*>)
eval-buffer(#<buffer  *load*> nil "/home/Roberto/.emacs.d/elpa/sml-mode-6.9/sml-mode.el" nil t)  ; Reading at buffer position 9890
load-with-code-conversion("/home/Roberto/.emacs.d/elpa/sml-mode-6.9/sml-mode.el" "/home/Roberto/.emacs.d/elpa/sml-mode-6.9/sml-mode.el" nil t)
sml-mode()
set-auto-mode-0(sml-mode nil)
set-auto-mode()
normal-mode(t)
after-find-file(t t)
find-file-noselect-1(#<buffer test.sml> "~/test.sml" nil nil "~/test.sml" nil)
find-file-noselect("~/test.sml" nil nil t)
find-file("~/test.sml" t)
funcall-interactively(find-file "~/test.sml" t)
call-interactively(find-file nil nil)
command-execute(find-file)

标签: emacssmlsmlnjsml-mode

解决方案


错误消息表明文件中的位置 9890 存在错误。就在 lambda 字符旁边:

  '(("fn" . ?λ)

由于这是文件中的第一个非 ASCII 字符,我猜该文件是用乱码编码或其他东西下载的。不知道为什么M-x list-packages不适合你——我想你可以通过手动编辑文件来解决这个问题。与Github上的这个版本进行比较,看看哪些字符应该出现在那里。


推荐阅读