尽管安装了 sml 模式,但 Emacs 中无法识别 SML 语法



>我已经在Emacs(版本26.2(中安装了软件包sml模式(版本6.9(,但是当我尝试打开.sml文件时,我在迷你缓冲区中收到以下错误:File mode specification error: (invalid-read-syntax ?)。因此,编辑器无法识别 SML 语法,这也很清楚当前模式显示SML以外的Fundamental模式。

以下是我为设置环境而执行的步骤:

  • 我首先在usr/local/sml安装了smlnj。
  • 我尝试安装预设的sml-mode包(M-x 列表包(。然而,这并没有成功。
  • 然后,我从机器中的 https://elpa.gnu.org/packages/sml-mode.html 下载了sml-mode-6.9.el的内容,并将其安装在Emacs(M-x软件包安装文件(上。
  • Emacs 中的软件包列表在sml-mode软件包旁边显示已安装,但显然不起作用。

使用 M-x 切换调试错误时给出以下堆栈跟踪:

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)

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

'(("fn" . ?λ)

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

也许M-x package-list-packages确实成功安装了sml-mode,但随后没有加载。

您能否验证目录~/.emacs.d/elpa/sml-mode-6.9是否存在?

sml-mode的唯一配置是软件包安装程序添加的内容:

(require 'package)
(setq package-archives
'(("gnu" . "http://elpa.gnu.org/packages/")
("marmalade" . "https://marmalade-repo.org/packages/")
("melpa" . "http://melpa.org/packages/")))
(package-initialize)
...
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
...
'(package-selected-packages
(quote
(... sml-mode ...))))

这应该以某种方式到达文件~/.emacs.d/elpa/sml-mode-6.9/sml-mode-autoloads.el,这使得sml-mode打开正确类型的文件时加载。

也许,您能否验证sml-mode在您的.emacs文件中是否也同样提到?

我正在使用Emacs 25并且sml-mode-6.7成功,除了你所做的之外,没有做任何事情。如果我升级到sml-mode-6.9此设置仍然有效。不幸的是,我无法测试它是否也适用于 Emacs 26。不幸的是,我不能说 25 和 26 之间是否有任何包管理器差异可以在这里发挥作用。

最新更新