Example of a plug-in with C++ code

The minimal plug-in

Consider the example of the minimal plug-in in the directory

    $TEXMACS_PATH/examples/plugins

It consists of the following files:

    minimal/Makefile
    minimal/progs/init-minimal.scm
    minimal/src/minimal.cpp

In order to try the plug-in, you first have to recursively copy the directory

    $TEXMACS_PATH/examples/plugins/minimal

to $TEXMACS_PATH/progs or $TEXMACS_HOME_PATH/progs. Next, running the Makefile using

    make

will compile the program minimal.cpp and create a binary

    minimal/bin/minimal.bin

When relaunching TeXmacs, the plug-in should now be automatically recognized.

How it works

The minimal plug-in demonstrates a minimal interface between TeXmacs and an extern program; the program minimal.cpp is explained in more detail in the chapter about writing interfaces. The initialization file init-minimal.scm essentially contains the following code:

(plugin-configure minimal

(:require (url-exists-in-path? "minimal.bin"))

(:launch "minimal.bin")

(:session "Minimal"))

The :require option checks whether minimal.bin indeed exists in the path (so this will fail if you forgot to run the Makefile). The :launch option specifies how to launch the extern program. The :session option indicates that it will be possible to create sessions for the minimal plug-in using TextSessionMinimal.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".