Example of a plug-in with Scheme code

The world plug-in

Consider the world plug-in in the directory

    $TEXMACS_PATH/examples/plugins

This plug-in shows how to extend TeXmacs with some additional Scheme code in the file

    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 World menu should appear in the menu bar).

How it works

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 World and a menu item WorldHello world, which can be used to insert the text “Hello world”. In general, the initialization routine should be very short and rather load a module which takes care of the real initialization. Indeed, keeping the init-myplugin.scm files simple will reduce the startup time of TeXmacs.

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".