PrologConsole Plugin Documentation

PrologConsole is a jEdit plug-in embedding a Prolog engine in the jEdit text editor. The chosen Prolog engine is tuProlog, a Java-based very light-weight Prolog system developed at the University of Bologna and Cesena. If you are reading this and want to download and install the plug-in, I assume that you are familiar with Prolog programming: so, I'm going to just explain how the plug-in and its interface work accomplishing the integration between jEdit and tuProlog.

The tuProlog Shell embedded in the Console plugin

The plugin is embedded as a shell in the Console plugin, so you must have the Console plugin installed in order to be able to use the PrologConsole plugin. You can then access the PrologConsole plugin only by starting the Console plugin and choosing the tuProlog shell from the drop-down list at the top left corner of the Console plugin interface.

How to use the tuProlog shell

To solve a Prolog goal using the the tuProlog shell you have to type the goal in the textfield provided by the Console plugin interface and press the Enter key (or press the "Run" button). tuProlog can solve goals using all the ISO predicates (e.g. write/1, is/2) and any predicate provided by the user.

To control the tuProlog system, the following predicates can be used:

When you are solving a goal with multiple solution, a "?" will appear after each solution, in order to ask the user if she wants to get another solution to the same goal. The user has two choices: Please note that a goal remains the engine's current goal until all of its solutions have been found, or the engine begin to solve another goal (this does not happens if the engine is asked to solve a goal with a syntax error in it).

Please refer to the Console plugin documentation if you want to know how to use the Console plugin interface and how the Console plugin works.

PrologConsole actions

Starting with version 0.4, PrologConsole defines some actions to be included in the Plugins menu.

The PrologConsole actions included in the Plugins menu

As you can see in the above picture, PrologConsole defines the following actions:

These actions are primarily defined so that you can assign them a shortcut and simply invoke those commands with a keystroke, rather than typing in the Console, which is an activity that could be a bit annoying, even using the history feature provided by the plugin.

Consulting Prolog theories at startup

Starting with the jEdit 4.1 series, you can write a script to be run by jEdit at startup in languages other than BeanShell, which was the only language supported by previous jEdit versions. Starting with version 0.4, PrologConsole registers a macro handler to jEdit, so that you can put Prolog startup scripts in the ~/.jedit/startup or %JEDIT-HOME%/startup directories and having them run by jEdit at startup.

But what exactly is a "Prolog startup script", and what are the effects of having it run at startup?

A Prolog startup script is just a Prolog theory containing facts and clauses. Having a Prolog script run at startup has the effect of feeding the Prolog engine with the theory contained in the script, so that you can immediately issue queries, involving that particular theory, to the Prolog engine, instead of relying on manual theory consulting as previous versions of PrologConsole forced you to. If a Prolog startup script contains a syntax error, the consulting silently fails, logging an InvalidTheoryException to the activity.log file in your ~/.jedit directory.

Please note that this feature is only available under the jEdit 4.1 series and above. Prolog scripts will not be run at startup under jEdit 4.0 and below, but you can have them consulted (i.e. feeded to the Prolog engine) through the Macros>Run Other Macro... menu command.

Requirements

The PrologConsole plug-in was developed under jEdit version 4.0final and embedded as a Console plugin shell, so the current requirements are: Console plugin version 3.2, and jEdit version 4.0final. The tuProlog engine (currenlty in version 1.2.0) is also required, but a copy is a provided within the PrologConsole zip archive.

jEdit can be found at http://www.jedit.org

tuProlog can be found at http://sourceforge.net/projects/tuprolog and at http://lia.deis.unibo.it/Research/2P.

Contacts

The plugin's author is Giulio Piancastelli, and can be contacted writing to gpian@softhome.net. Please note that I am not the jEdit or Console plugin main developer, nor the tuProlog mantainer: please report to me bugs and suggestions related to the PrologConsole plugin only, and report the ones related to the text editor or the Console plugin or the Prolog system to their respective authors.

Change Log

Version 0.4
Added two actions (Consult Current Buffer, Clear Engine and Consult) to the jEdit Plugins menu. Registered a Macros.Handler so that an user can have Prolog theories consulted at startup (note that this feature works only under the jEdit 4.1 series and above -- see the plugin documentation for further details). Requires jEdit 4.0final, Console 3.2 and tuProlog 1.2.0.
Version 0.3
Added lazy initialization of the Prolog engine, in order to lighten the burden on the jEdit startup time. The Console text area is now enabled to display the engine's spy information when solving a Prolog goal (see the use of the spy/0 and nospy/0 predicates in the tuProlog documentation). Added a missing docs property in the PrologPlugin.props file. Requires jEdit 4.0final, Console 3.2 and tuProlog 1.2.0.
Version 0.2
Rewritten to make the plugin a Console shell. Requires jEdit 4.0final, Console 3.2 and tuProlog 1.1.0.
Version 0.1
Initial release. Developed under jEdit 4.0final and tuProlog 1.1.0.