簡體   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