![]() |
Writing your own plug-ins | ![]() |
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):
For binary files. This directory is appended to the PATH.
For documentation. This directory is added to TEXMACS_DOC_PATH.
langs/natural/dic
For dictionaries. This directory is added to TEXMACS_DIC_PATH.
For shared libraries. This directory is added to LD_LIBRARY_PATH.
misc/patterns,
misc/pixmaps,
misc/themes
For background patterns, icons and themes.
For style packages.
For Scheme programs. This directory is added to the load path of Scheme modules.
For source files (this directory is not used by TeXmacs itself).
For style files.
For text files.
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. Since these search paths are computed only once at startup, TeXmacs has to be restarted after the creation of a new plug-in or of a new subdirectory of a plug-in.
Similarly, plugin documentation is intended to be automatically added to the Help\(\rightarrow\)Plug-ins submenu. For this automation to work, the myplugin/doc/ directory should contain at least two files
myplugin.en.tm
myplugin-abstract.en.tm
The first file is the main entry point to the plugin's documentation and should follow the general conventions for structuring TeXmacs documentation. The -abstract file provides a short description of the plugin's functionality.
Example 1. The easiest type of plug-in only consists of data files, such as a collection of style files and packages. In order to create such a plug-in, it suffices to create directories
$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 Document\(\rightarrow\)Style and Document\(\rightarrow\)Use package menus.
For more complex plug-ins, such as plug-ins with additional Scheme or C++ code, one usually has to provide a Scheme configuration file
$TEXMACS_HOME_PATH/plugins/myplugin/progs/init-myplugin.scm
The name of this file has to be exactly init-myplugin.scm, where myplugin is the name of the plug-in directory. The file is not loaded immediately at startup, but about one second later, when TeXmacs becomes idle (or earlier, when information about all plug-ins is needed); see the section on internals. 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
In the source code of TeXmacs, the second directory corresponds to
src/plugins
. Some of these plug-ins are described in more detail in the chapter about writing new interfaces.