7.12 Creating New Modules

Sweep integrates with the Emacs auto-insert command to assist you with creating of new SWI-Prolog modules. You can use auto-insert to populate new Prolog files with module template.

User Option: sweeprolog-module-header-comment-skeleton

Additional content to put in the topmost comment in Prolog module headers.

The command auto-insert in Sweep Prolog mode inserts a Prolog module skeleton that begins with a module header multi-line comment. By default, this header includes your name and email address (user-full-name and user-mail-address respectively). If you want the header to contain more information, you can extend it to suite yours needs by customizing sweeprolog-module-header-comment-skeleton. This can be useful, for example, for including copyright text in the header.

After the header, the module skeleton inserts a module/2 directive with the module name set to the base name of the file.

Lastly the skeleton includes a ‘PlDoc’ module comment for you to fill with the module’s documentation (see File comments in the SWI-Prolog manual).

As an example, open a new Prolog file and call it foo.pl by typing C-x C-f foo.pl RET, and insert the module skeleton with M-x auto-insert RET. The buffer contents should now be as follows:

/*
    Author:        John Doe
    Email:         [email protected]

*/

:- module(foo, []).

/** <module>

*/

To automatically insert the module skeleton whenever you open a new Prolog file, enable the minor mode auto-insert-mode. See Autoinserting in the Autotyping manual, for detailed information about auto-insert and its customization options.