2

我正在尝试为 emacs 21.4.1 安装 lua-mode(版本 20110428)并且遇到问题。在我的 .emacs 文件中,我有:

(add-to-list 'load-path "~/.emacs.d/lua-mode/")
...
(setq auto-mode-alist (cons '("\\.lua$" . lua-mode) auto-mode-alist))
(autoload 'lua-mode "lua-mode" "Lua editing mode." t)

我使用了这里的安装说明:http: //lua-mode.luaforge.net/ 另外,在我的 .emacs.d/ 目录中,我有 lua-mode/ 包含 lua-mode.el。所有这些文件都具有正确的权限。

除了现在当我使用 emacs 打开新文件“test.lua”时,我在暂存缓冲区中收到以下消息:

“文件模式规范错误:(void-function called-interactively-p)”

我正在运行 RHEL5。我在网上查过,但没有找到太多帮助。有没有人有什么建议?我不知道任何 LISP(因此很难调试 lua-mode.el),除了一些快捷方式之外,我对 emacs 了解不多。

谢谢。

4

4 回答 4

4

您正在使用的 Emacs 版本没有带有 1 个参数的“调用交互 p”函数版本(该函数的早期版本没有参数)。您可以通过将此解决方法(在此处发布:http: //paste.lisp.org/display/115598/raw)放在您的 Emacs 初始化文件中来解决此问题:

(condition-case nil (called-interactively-p 'interactive)
  (error
   ; Save reference to called-interactively-p in
   ; inglorion-system-called-interactively-p
   (fset 'inglorion-system-called-interactively-p
         (symbol-function 'called-interactively-p))
   ; Define called-interactively-p so that it discards
   ; its arguments and calls inglorion-system-called-interactively-p
   (fset 'called-interactively-p
         (lambda (&rest args)
           (inglorion-system-called-interactively-p)))))

但是,当我这样做并尝试使用 Emacs 22 进行测试时,由于某些功能不存在,我也遇到了其他错误,因此如果您想使用 lua 模式,您可能必须升级您的 Emacs 版本。

使用 Emacs 23 和 24,“lua-mode.el”似乎可以使用现有的 lua 文件(我不是 lua 程序员,所以我无法正确测试它),但是当您尝试创建新的 lua 文件时会中断。它实际上是当您尝试打开一个新的 lua 文件时出现的“lua-mode.el”代码中的一个错误(如果您尝试打开现有的 lua 文件则不会发生)。问题是第 1218 行的“remove-text-properties”调用(在“lua-unmark-multiline-literals”函数中)正在调用“remove-text-properties”函数,开始值为“1”和“0”的结束值(它是“0”,因为新文件的缓冲区大小为“0”。您可以通过将第 1218 行更改为:

    (remove-text-properties (or begin 1) (or end (buffer-size)) '(syntax-table ()))

至:

    (remove-text-properties (or begin 1)
                            (or end
                                (if (> (buffer-size) 0)
                                    (buffer-size)
                                  (or begin 1)))
                            '(syntax-table ()))

你应该让“lua-mode.el”的开发者知道这个错误,并且可能还请求支持早期的 Emacs 版本。

于 2011-07-27T18:08:40.653 回答
2

我恰好是lua-mode的维护者。我很幸运在网上冲浪时偶然发现了您的问题,并且在有人慷慨地提供了called-interactively-p功能的备份实现后,我的问题得到了解决。

同时,我必须承认我很清楚called-interactively在 emacs23 之前的某处逻辑已经改变,但我没有费心去改变它,直到有人将它作为一个错误提交。这只是一个努力优化,因为最近 Emacs 中发生了许多内部 API 更改,并且抢先修复它们根本不适合我的时间表。

底线是:

  1. 我将在不久的将来在 lua-mode 中提供 call-interactively-p 的备份实现,它将进入下一个版本。
  2. 我想鼓励您在此处提交诸如错误报告之类的故障。我会定期阅读它们,上游欢迎您的报告以及您自己的技巧。

干杯,immerrr。

于 2011-09-14T13:14:00.403 回答
1

我认为 Emacs 21.4 中不存在函数 `call-interactively-p'。

但实际上,我认为您在谈论 XEmacs,而不是 GNU Emacs。请注意,这是 2 个不同的项目。

您应该将您的 XEmacs 升级到 21.5 beta 或更高版本 (YMMV),可能使用 GNU Emacs 23。

于 2011-07-27T16:19:39.007 回答
0

我也有这个问题。我可以通过更改它来修复它:

(add-to-list 'auto-mode-alist '("\\.lua\\'" . lua-mode))

我不能声称知道为什么这会有所不同:我从其他一些逻辑推断加载 javascript 模式,该模式使用类似的语法来描述文件扩展名。

于 2011-07-27T13:56:49.190 回答