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

    Those who start to study and / or work with SWI-Prolog ( 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 for details.
    For help, use? - help (Topic). or? - apropos (Word).
    ? - 

    Even having managed to call the source code editor, many find it difficult to work with it because the keyboard shortcuts correspond to the quite charismatic and different Emacs editor.

    How to fix it?

    Type “help.” At the command prompt
    ? - help.

    You will see something like this:

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

    Here you need to find the following line:

    % :- set_prolog_flag(editor, pce_emacs).

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

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

    In this window, you need to execute the menu item File / Edit Preferences / XPCE User Defaults (a confirmation dialog may also appear where you need to answer in the affirmative).

    In the window that opens, find the line
    ! cua

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

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

    At the command prompt, enter:

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

    In the file that appears, type:

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

    From the menu, select Compile / Compile buffer.

    Go to the console: type main there .:

    ? - main.

    You saw a solution to the quadratic equation.

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

    Also popular now: