📜 ⬆️ ⬇️

Configuring the SWI-Prolog source editor (XPCE Emacs) for a user not familiar with Emacs keyboard shortcuts

Those who begin to study and / or work with SWI-Prolog (http://www.swi-prolog.org/) often often encounter a not-so-friendly command line interface in this style:

 dm @ dms: ~> swipl
 % library (swi_hooks) compiled into pce_swi_hooks 0.00 sec, 3,856 bytes
 % /home/dm/.plrc compiled 0.00 sec, 656 bytes
 Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 5.10.2)
 Copyright (c) 1990-2010 University of Amsterdam, VU Amsterdam
 SWI-Prolog comes with ABSOLUTELY NO WARRANTY.  This is free software,
 and you are welcome to redistribute it under certain conditions.
 Please visit http://www.swi-prolog.org for details.

 For help, use? - help (Topic).  or? - apropos (Word).

 ? - 


Even having managed to call the editor of the source code, many find it difficult to work with it due to the fact that the keyboard shortcuts correspond to a fairly charismatic and different from other Emacs editor.
')
How to fix it?

Type in the command line "help."
 ? - help.


You will see something like this:



In the window, you need to perform the menu item Settings / User init file ... (if a confirmation dialog box appears - confirm the creation of the file):



There you need to find this line:

% :- set_prolog_flag(editor, pce_emacs). 


And remove the “%” symbol in it, then save the file by calling the menu File / Save buffer.

Then, in the first window of the help (SWI-Prolog Help) you need to run the item Help / XPCE (GUI) Manual.
A window like this will appear:



In this window, you need to run the menu item File / Edit Preferences / XPCE User Defaults (you may also see a confirmation dialog where you need to answer yes).

In the window that opens, you need to find the line
 ! key_binding.style: cua


And remove the “!” Symbol in it at the beginning, then save the file by executing the menu item File / Save buffer.

Then you need to close all windows and run SWI-Prolog again.

In the command line that appears, enter:

 ? - edit (file ('My file.pl')).


In the file that appears, type:



After that, press Control + S, the file should be saved to disk.

From the menu, select Compile / Compile buffer.

Go to the console: type there main .:

 ? - main.
 2.0
 true


You saw a solution to a quadratic equation.

Now you know how to create new files (edit (file (<file>))., Save them with the familiar combination (Control S) and even how to solve equations with SWI-Prolog.

Source: https://habr.com/ru/post/244055/


All Articles