MLton 20100608 EmacsBgBuildMode
Home  Index  
Do you really want to think about starting a build of you project? What if you had a personal slave that would restart a build of your project whenever you save any file belonging to that project? The bg-build mode does just that. Just save the file, a compile is started (silently!), you can continue working without even thinking about starting a build, and if there are errors, you are notified (with a message), and can then jump to errors.

This mode is not specific to MLton per se, but is particularly useful for working with MLton due to the longer compile times. By the time you start wondering about possible errors, the build is already on the way.

Functionality and Features

Download

There is no package for the mode at the moment. To install the mode you need to fetch the Emacs lisp, *.el, files from the MLton repository: [WWW]emacs.

Setup

The easiest way to load the mode is to first tell Emacs where to find the files. For example, add

to your ~/.emacs or ~/.xemacs/init.el. You'll probably also want to start the mode automatically by adding

to your Emacs init file. Once the mode is activated, you should see the BGB indicator on the mode line.

MLton and Compilation-Mode

At the time of writing, neither Gnu Emacs nor XEmacs contain an error regexp that would match MLton's messages.

If you use Gnu Emacs, insert the following code into your .emacs file:

If you use XEmacs, insert the following code into your init.el file:

Usage

Typically projects are built (or compiled) using a tool like [WWW]make, but the details vary. The bg-build mode needs a project configuration file to know how to build your project. A project configuration file basically contains an Emacs Lisp expression calling a function named bg-build that returns a project object. A simple example of a project configuration file would be the ([WWW]Build.bgb) file used with smlbot:

The bg-build function takes a number of keyword arguments:

All of the keyword arguments, except :shell, are optional and can be left out.

Note the use of the nice command above. It means that background build process is given a lower priority by the system process scheduler. Assuming your machine has enough memory, using nice ensures that your computer remains responsive. (You probably won't even notice when a build is started.)

Once you have written a project file for bg-build mode. Use the bg-build-add-project command to load the project file for bg-build mode. The bg-build mode can also optionally load recent project files automatically at startup.

After the project file has been loaded and bg-build mode activated, each time you save a file in Emacs, the bg-build mode tries to build your project.

The bg-build-status command creates a buffer that displays some status information on builds and allows you to manage projects (start builds explicitly, remove a project from bg-build, ...) as well as visit buffers created by bg-build. Notice the count of started builds. At the end of the day it can be in the hundreds or thousands. Imagine the number of times you've been relieved of starting a build explicitly!


Last edited on 2007-07-07 04:01:31 by VesaKarvonen.