emacs - emacs 上的 ediprolog 奇怪行为

标签 emacs prolog swi-prolog

我对使用 emacs 和自定义它还很陌生。

我正在尝试安装ediprolog

我的 .emacs 文件是:

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.
 '(inhibit-startup-screen t))
(custom-set-faces
 ;; custom-set-faces 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.
 )

(global-set-key [f10] 'ediprolog-dwim)

(setq load-path (cons "/home/sam/Documents/emacs/prolog" load-path))
(autoload 'run-prolog "prolog" "Start a Prolog sub-process." t)
(autoload 'prolog-mode "prolog" "Major mode for editing Prolog programs." t)
(autoload 'mercury-mode "prolog" "Major mode for editing Mercury programs." t)
(setq prolog-system 'swi)
(setq auto-mode-alist (append '(("\\.pl\\'" . prolog-mode)
                                ("\\.m\\'" . mercury-mode))
                               auto-mode-alist))

我使用 M-x package-install RET ediprolog RET 安装了 ediprolog

我已经使用 %?- member(X,[a,b,c]) 创建了一个测试文件。 如果我按 F10space space space 在此查询时,我得到以下输出:

%?- member(X,[a,b,c]).
%@  member(X,[a,b,c]^H^H^H^H^H^H^H[a,b,c])^H^H^H^H^H^H^H^H^H^H^H(X,[a,b,c]).^M
%@ X = a ;^M
%@ X = b ;^M
%@ X = c.^M
%@^M

这显然不正确,因为我有所有这些额外的 ^H^M 字符。

此外,如果我按照指示将行 (require 'ediprolog) 添加到我的 .emacs 中,则在启动 emacs 时会出现以下错误:

Warning (initialization): An error occurred while loading `/home/sam/.emacs':

File error: Cannot open load file, no such file or directory, ediprolog

To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file.  Start Emacs with
the `--debug-init' option to view a complete error backtrace.

我还按照 https://bruda.ca/emacs/prolog-mode_installation_guide 中的说明进行操作安装序言模式(如果相关)。

最佳答案

这是由于 SWI-Prolog 最近切换到 editline 库而导致的,而之前它默认使用 readline

问题现已解决。

SWI-Prolog 7.5.1 及更高版本包含 change使 ediprolog 再次工作,无需对 Emacs 或 ediprolog 进行任何升级或配置更改。

即将推出的 SWI-Prolog 稳定版本 (7.4) 也包含此更改。

因此,只有极少数版本(特别是 7.5.0 和 7.4-rc1)受到此问题的影响。


如果您使用的 SWI-Prolog 版本出现此问题,以下是可能的解决方法:

解决此问题的一种方法是将以下内容放入 ~/.swiplrc 初始化文件中:

:- set_prolog_flag(readline, readline).

假设您安装了 readline,这应该会产生一个有效的 ediprolog

或者,您也可以输入:

:- set_prolog_flag(readline, false).

在您的~/.swiplrc初始化文件中。然而,如果您在系统终端上调用 SWI-Prolog,这也会完全禁用 SWI-Prolog 的行编辑功能。在这种情况下,您当然可以使用 -f none 忽略初始化文件。

或者,您也可以将以下内容放入 .emacs 中:

(setq ediprolog-program-switches '("-g" "set_prolog_flag(readline, false)"))

如果您的 SWI-Prolog 版本足够新,则不再需要这些解决方法。

关于emacs - emacs 上的 ediprolog 奇怪行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42084661/

相关文章:

prolog - 如何根据 prolog 中的 2 个列表创建索引值列表

prolog - ?- X 的详细含义是 X+1

prolog - PROLOG 中的深度逆向 - 列表

prolog - 在第一个答案之后,Prolog 显示错误 "char_code/2: Cannot represent due to ' character_code'"

prolog - SWI-Prolog 中的 "strptime"

command-line - 从终端查询不会打印任何内容

python - 如何在 shell 中运行 emacs lisp 解释器?

模仿 emacs CTL-K 的 Vim 键绑定(bind)

c - cedet语义解析我系统的c头文件时,出现 "Idle Parse Error":

button - 如何获取调用函数的可点击文本