繁体   English   中英

关于emacs奇怪行为的ediprolog

[英]ediprolog on emacs strange behaviour

我刚开始使用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))

我使用Mx package-install RET ediprolog RET

我用%?- member(X,[a,b,c]).创建了一个测试文件%?- member(X,[a,b,c]). 如果在此查询中按F10键并按space space spacespace space space键, F10得到以下输出:

%?- 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最近切换到编辑线库引起的,而默认情况下它先前使用的是readline

现在问题已解决。

SWI-Prolog的7.5.1和更高版本包含一个变化 ,使ediprolog再次工作,而不需要任何升级或Emacs或配置更改ediprolog

此外,即将发布的SWI-Prolog稳定版本(7.4)也附带此更改。

因此,只有很少的版本(尤其是7.5.0和7.4-rc1)受此问题影响。


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

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

\n :-set_prolog_flag(readline,readline)。\n

假设您已安装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版本足够新,则不再需要这些解决方法。

对于(require 'ediprolog)的问题,您只需要在~/.emacs前面添加(package-initialize) (最近的Emacsen会为您完成)。 但是由于您是从ELPA安装的,因此您无需明确require它: ediprolog-dwim应该仍然为您自动加载。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM