![]() |
TeXmacs plug-ins | ![]() |
There are many ways in which TeXmacs can be customized or extended: users may define their own style files, customize the user interface, or write links with extern programs. The plug-in system provides a universal mechanism to combine one or several such extensions in a single package. Plug-ins are both easy to install by other users and easy to write and maintain.
From the user's point of view, a plug-in myplugin will usually be distributed on some web-site as a binary tarball with the name
myplugin-version-architecture.tar.gz
If you installed TeXmacs yourself in the directory $TEXMACS_PATH, then you should unpack this tarball in the directory $TEXMACS_PATH/plugins, using
tar -zxvf myplugin-version-architecture.tar.gz
This will create a myplugin subdirectory in $TEXMACS_PATH/plugins. As soon as you restart TeXmacs, the plug-in should be automatically recognized. Please read the documentation which comes with your plug-in in order to learn using it.
cd myplugin; make
or
cd myplugin; ./configure; make
rm -rf myplugin
and reinstall as explained above.
In order to write a plug-in myplugin, you should start by creating a directory
$TEXMACS_HOME_PATH/plugins/myplugin
where to put all your files (recall that $TEXMACS_HOME_PATH defaults to $HOME/.TeXmacs). In addition, you may create the following subdirectories (when needed):
As a general rule, files which are present in these subdirectories will be automatically recognized by TeXmacs at startup. For instance, if you provide a bin subdirectory, then
$TEXMACS_HOME_PATH/plugins/myplugin/bin
will be automatically added to the PATH environment variable at startup. Notice that the subdirectory structure of a plug-in is very similar to the subdirectory structure of $TEXMACS_PATH.
$TEXMACS_HOME_PATH/plugins/myplugin
$TEXMACS_HOME_PATH/plugins/myplugin/styles
$TEXMACS_HOME_PATH/plugins/myplugin/packages
and to put your style files and packages in the last two
directories. After restarting TeXmacs, your style files and packages
will automatically appear in the
For more complex plug-ins, such as plug-ins with additional
$TEXMACS_HOME_PATH/plugins/myplugin/progs/init-myplugin.scm
This configuration file should contain an instruction of the following form
(plugin-configure myplugin
configuration-options)
Here the configuration-options describe the principal actions which have to be undertaken at startup, including sanity checks for the plug-in. In the next sections, we will describe some simple examples of plug-ins and their configuration. Many other examples can be found in the directories
$TEXMACS_PATH/examples/plugins
$TEXMACS_PATH/plugins
Some of these are described in more detail in the chapter about writing new interfaces.
Consider the world plug-in in the directory
$TEXMACS_PATH/examples/plugins
This plug-in shows how to extend TeXmacs with some additional
world/progs/init-world.scm
In order to test the world plug-in, you should recursively copy the directory
$TEXMACS_PATH/examples/plugins/world
to $TEXMACS_PATH/plugins or $TEXMACS_HOME_PATH/plugins.
When relaunching TeXmacs, the plug-in should now be automatically
recognized (a
The file init-world.scm essentially contains the following code:
(define (world-initialize)
(menu-extend texmacs-extra-menu
(=> "World"
("Hello world" (insert-string "Hello world")))))
(plugin-configure world
(:require #t)
(:initialize (world-initialize)))
The configuration option :require specifies a condition which needs to be satisfied for the plug-in to be detected by TeXmacs (later on, this will for instance allow us to check whether certain programs exist on the system). The configuration is aborted if the requirement is not fulfilled.
The option :initialize specifies an instruction which
will be executed during the initialization (modulo the fulfillment of
the requirement). In our example, we just create a new top level menu
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.
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
As explained before, the
(plugin-configure myplugin
configuration-options)
Here follows a list of the available configuration-options: