简体   繁体   中英

ediprolog on emacs strange behaviour

I am newish to using emacs and customising it.

I am trying to install ediprolog

My .emacs file is:

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))

I installed ediprolog with Mx package-install RET ediprolog RET

I have created a test file with %?- member(X,[a,b,c]). If I press F10 and space space space when on this query I get the following output:

%?- 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

This is clearly not correct as I have all these extra ^H and ^M characters.

Also if I add the line (require 'ediprolog) to my .emacs as instructed I get the following error on starting 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.

I also have followed the instructions at https://bruda.ca/emacs/prolog-mode_installation_guide to install the prolog-mode if that is relevant.

This is caused by SWI-Prolog's recent switch to the editline library, whereas it previously used readline by default.

The issue is now solved.

SWI-Prolog 7.5.1 and later contain a change that make ediprolog work again, without requiring any upgrades or configuration changes of Emacs or ediprolog .

Also the upcoming stable version (7.4) of SWI-Prolog ships with this change.

Therefore, only very few versions (notably 7.5.0 and 7.4-rc1) are affected by this problem.


If you are using a version of SWI-Prolog where this issue shows up, here are possible workarounds:

One way to solve this is to put the following in your ~/.swiplrc initialization file:

\n \n

This should yield a working ediprolog , assuming you have readline installed.

Alternatively, you can also put:

:- set_prolog_flag(readline, ).

in your ~/.swiplrc initialization file. However, this completely disables the line editing facilities of SWI-Prolog also if you invoke it on the system terminal. You can of course use -f none to ignore the initialization file in such cases.

Alternatively, you can also put the following in your .emacs :

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

If your version of SWI-Prolog is sufficiently recent, these workarounds are no longer needed.

For the problem with (require 'ediprolog) , you simply need to add (package-initialize) earlier in your ~/.emacs (recent Emacsen will do this for you). But since you installed it from ELPA, you shouldn't need to require it explicitly: ediprolog-dwim should autoload for you anyway.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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