2

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

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

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

使用 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)
4

2 回答 2

1

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

  '(("fn" . ?λ)

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

于 2019-09-13T14:58:10.837 回答
0

也许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 之间是否有任何包管理器差异可以在这里发挥作用。

于 2019-09-12T12:56:47.647 回答