![]() |
How the plug-in system works internally | ![]() |
This chapter describes the implementation of the plug-in system, for developers who want to write non-trivial plug-ins or who need to debug or modify the plug-in machinery itself. It complements the user-level description in the previous sections and the chapter about interfacing TeXmacs with other programs.
The implementation is spread over the following files (Scheme files are given relative to
src/TeXmacs/progs
, C++ files relative to
src/src
):
System/Boot/init_texmacs.cpp
Discovery of the plug-in directories (plugin_list) and extension of the search paths with the subdirectories of all plug-ins (plugin_path).
kernel/texmacs/tm-plugins.scm
The plugin-configure macro, the plug-in cache, lazy initialization, the tables of connections, sessions and scripting languages, and remote plug-ins.
utils/plugins/plugin-eval.scm
Queues of pending evaluations, the notification call-backs from the C++ side, silent (background) evaluations and plugin-eval.
utils/plugins/plugin-cmd.scm
Serialization of the input, formatting of special commands, and the tables for tab-completion, input completeness tests and numeric evaluation.
utils/plugins/plugin-convert.scm
Conversion of mathematical input into strings (plugin-input-converters).
dynamic/session-edit.scm,
dynamic/session-menu.scm
Shell sessions.
dynamic/scripts-edit.scm
Evaluation of scripts inside documents.
System/Link/
The C++ side of connections:
connection.cpp
(the connection resource),
tm_link.hpp
(the abstract tm_link_rep class and the control characters),
pipe_link.cpp
,
dyn_link.cpp
,
cmdline_link.cpp
and
request_link.cpp
. Under Windows (and for Qt builds with QTPIPES), pipes are implemented by
Plugins/Qt/qt_pipe_link.cpp
instead of
pipe_link.cpp
.
Data/Convert/Generic/input.cpp
The parser for the output of plug-ins (texmacs_input_rep).
The Scheme function (plugin-list) is implemented by the C++ function plugin_list in
System/Boot/init_texmacs.cpp
. It returns the sorted list of the names of all subdirectories of
$TEXMACS_PATH/plugins /etc/TeXmacs/plugins $TEXMACS_HOME_PATH/plugins /usr/share/TeXmacs/plugins |
Duplicates are removed, as well as entries ending with .txt or .md (such as the README.md file of the plug-in collection). If a plug-in named jupyter is present, it is moved to the front of the list, so that it is initialized before all other plug-ins: the jupyter plug-in overloads alt-launcher in order to redirect the launchers of other plug-ins.
In the source tree, the plug-ins which are shipped with TeXmacs live in
src/plugins
; the build system copies them into TeXmacs/plugins (which is not under version control), and the installation procedure installs them into $TEXMACS_PATH/plugins. The small example plug-ins of the chapter about interfaces live in $TEXMACS_PATH/examples/plugins and are not in the plug-in search path: they have to be copied into one of the above directories.
At startup, init_env_vars extends a number of environment variables with the corresponding subdirectories of all plug-ins, using the helper plugin_path:
static url
plugin_path (string which) {
url base= "$TEXMACS_HOME_PATH:/etc/TeXmacs:$TEXMACS_PATH:/usr/share/TeXmacs";
url search= base * "plugins" * url_wildcard ("*") * which;
return expand (complete (search, "r"));
} |
The following table summarizes which subdirectories of a plug-in are taken into account:
| Subdirectory | Added to | Purpose |
| progs | GUILE_LOAD_PATH | Scheme modules and init-name.scm |
| bin | PATH (appended) | helper executables |
| lib | LD_LIBRARY_PATH | shared libraries for :link |
| styles | TEXMACS_STYLE_ROOT | style files |
| packages | TEXMACS_PACKAGE_ROOT | style packages |
| texts | TEXMACS_TEXT_ROOT | text files |
| doc | TEXMACS_DOC_PATH | documentation |
misc/patterns |
TEXMACS_PATTERN_PATH | background patterns |
misc/pixmaps |
TEXMACS_PIXMAP_PATH | icons |
misc/themes |
TEXMACS_THEME_PATH | themes |
langs/natural/dic |
TEXMACS_DIC_PATH | dictionaries |
The style and package roots are searched recursively (through search_sub_dirs), so that a package myplugin/packages/session/myplugin.ts is found. Since wildcards are expanded only for existing directories and only once at startup, TeXmacs has to be restarted after installing a new plug-in or after creating a new subdirectory (such as a bin directory produced by a compilation).
Since the progs directories of all plug-ins are in the load path, Scheme modules of plug-ins are simply named after their file names. For instance, the module in
plugins/python/progs/python-menus.scm
is declared as (texmacs-module (python-menus) …) and loaded using (import-from (python-menus)).
Near the end of
init-texmacs.scm
, all plug-ins are scheduled for initialization:
(for-each lazy-plugin-initialize (plugin-list)) |
The function lazy-plugin-initialize (in
kernel/texmacs/tm-plugins.scm
) marks the plug-in in the table plugin-initialize-todo and postpones the actual initialization using (delayed (:idle 1000) (plugin-initialize name)), that is, until TeXmacs has been idle for one second. This keeps the startup time low, even when many plug-ins are installed.
The function (plugin-initialize name) first loads the plug-in cache (plugin-load-setup), and then loads the file plugins/name/progs/init-name.scm, which is searched in $TEXMACS_HOME_PATH and $TEXMACS_PATH (in this order). When the last plug-in has been initialized, the cache is saved (plugin-save-setup) if it had to be rebuilt.
Remark 1. The initialization file is only searched in $TEXMACS_HOME_PATH and $TEXMACS_PATH, although plugin_list and plugin_path also look into /etc/TeXmacs/plugins and /usr/share/TeXmacs/plugins. For a plug-in installed in one of the latter directories, the search paths are extended, but its initialization file is not loaded.
Whenever some code needs complete information about the available plug-ins, it calls (lazy-plugin-force), which immediately initializes all plug-ins which are still pending. This is done automatically by connection-defined?, connection-info, connection-variants, session-list, scripts-list, connection-get-handlers and write-local-plugin-info, as well as by the menus which list sessions and scripting languages. For instance, opening the Insert\(\rightarrow\)Session menu before the idle timer has fired loads all plug-ins at once.
Consequently, the initialization file should be fast and should not do more than necessary. A good practice is to keep init-myplugin.scm small, and to load the real implementation lazily from a (when (supports-myplugin?) …) block, using lazy-menu, lazy-keyboard, lazy-define, lazy-input-converter or import-from.
Testing whether a plug-in is supported usually requires to search the PATH for executables and sometimes to run them (for instance in order to determine their version). The results of these tests are therefore cached in the file
$TEXMACS_HOME_PATH/system/cache/plugin_cache.scm |
The file contains a list with three elements: the original value of the PATH when the cache was created (get-original-path), the table plugin-data-table as an association list, and a table which associates to each directory of the PATH its last modification time. The table plugin-data-table maps the name of each plug-in to the result of its :require or :versions option; it also contains the unevaluated :prioritary expressions under keys of the form (name :prioritary).
When loading the cache, plugin-load-setup checks, using path-up-to-date?, that the PATH did not change and that none of its directories has been modified since. If this is the case, the global variable reconfigure-flag? is set to #f: during the subsequent evaluation of plugin-configure, the options :require, :versions and :setup are skipped and the cached values are used. Otherwise the cache is rebuilt.
The cache can be invalidated explicitly:
Clear all connection tables, set reconfigure-flag? and re-run the initialization files of all plug-ins. This is what Tools\(\rightarrow\)Update\(\rightarrow\)Plugins and Insert\(\rightarrow\)Session\(\rightarrow\)Redetect do. It is also called after changing the manual path to plug-in binaries (set-manual-path) or an API key (set-manual-key).
Same as above, but only for the plug-in name. The jupyter plug-in uses this when the user toggles whether a language should be run via Jupyter.
Removing the cache file by hand has the same effect as reinit-plugin-cache at the next startup. This is a useful debugging step when a plug-in is unexpectedly (not) detected, for instance after installing a helper application in a directory whose modification time was not changed.
Processing the options of plugin-configure fills a number of hash tables in
tm-plugins.scm
: connection-variant maps pairs (name variant) to a description of the launcher, such as (tuple "pipe" shell-cmd), (tuple "dynlink" lib symbol init), (tuple "cmdline" cmd-fun result-fun) or (tuple "request" request-fun result-fun); connection-varlist contains the list of variants of each plug-in; connection-session and connection-scripts map plug-in names to their menu names; connection-handler contains the channel handlers. The following functions give access to this information:
(connection-defined? name)
(connection-list)
Test whether a connection with the given name was declared (locally or remotely), return the sorted list of all declared connections, resp. the list of variants of a connection. The function local-connection-variants only returns the local variants.
Return the launcher description for the session session of the plug-in name. If the session name contains a colon, then only the part before the colon is used as the variant, so that several sessions variant:1, variant:2, etc. may use the same launcher. If there is no launcher for the given variant, the first variant is used. This function is called from C++ by connection_start.
(session-list), (session-defined? name), (session-name name)
Plug-ins declared with :session resp. :scripts, and their menu names. The tables initially contain an entry for the built-in scheme language (notice that reinit-plugin-cache clears the tables without restoring this entry).
The capabilities of a plug-in are tested with the following predicates, which take the name of the plug-in as argument:
The plug-in was configured with (:tab-completion #t) (
plugin-cmd.scm
).
The plug-in was configured with (:test-input-done #t) (
plugin-cmd.scm
).
The plug-in declared mathematical input converters using plugin-input-converters (
plugin-convert.scm
).
Inside a session, the predicates (session-supports-completions?) and (session-supports-input-done?) (in
dynamic/session-edit.scm
) combine these tests with the current value of prog-language and the status of the connection. The function (plugin-approx-command-ref name) returns the name of the function which should be used for numeric evaluation in scripts (it is set by plugin-approx-command-set!, for instance to "float" by the maxima plug-in).
When the user evaluates an input field in a session, the following sequence of calls takes place (all Scheme functions are defined in
dynamic/session-edit.scm
or
utils/plugins/plugin-eval.scm
):
session-feed preprocesses the input (conversion of mathematical input if the option :math-input is present), marks the output as busy and calls plugin-feed.
plugin-feed appends the request to the queue of pending evaluations for the pair (language, session), together with four call-backs (do, notify, next and cancel). If the queue was empty, plugin-do is called.
If the connection is not alive yet (status 0), plugin-do first inserts a special start request, which calls plugin-start and hence the C++ function connection_start. Otherwise the do call-back of the first request is called, which eventually calls plugin-write.
plugin-write calls connection-write, which is implemented by connection_write in
System/Link/connection.cpp
. This function serializes the tree by calling back the Scheme function plugin-serialize and writes the resulting string to the link.
For the scheme language, plugin-write does not use any link, but directly evaluates the input with scheme-eval.
The C++ class connection_rep is a resource indexed by the string name-session. Its main fields are the underlying tm_link, a status and two parsers tm_out and tm_err of type texmacs_input for the standard output and the standard error of the application. The function connection_start calls connection-info and creates a link of the appropriate type:
if (is_tuple (t, "pipe", 1)) {
tm_link ln= make_pipe_link (t[1]->label);
con= tm_new<connection_rep> (name, session, ln);
}
else if (is_tuple (t, "dynlink", 3)) {
tm_link ln=
make_dynamic_link (t[1]->label, t[2]->label, t[3]->label, session);
con= tm_new<connection_rep> (name, session, ln);
} |
("cmdline" and "request" tuples are handled in a similar way.) The status of a connection is one of the constants defined in
System/Link/tm_link.hpp
:
#define CONNECTION_DEAD 0
#define CONNECTION_DYING 1
#define WAITING_FOR_INPUT 2
#define WAITING_FOR_OUTPUT 3 |
A pipe link (pipe_link_rep) forks a child process which executes the launcher using /bin/sh -c, with its standard input, output and error redirected to three pipes. The child is put into its own process group (setsid). Socket notifiers are attached to the output and error pipes, so that connection_rep::listen is called whenever data arrives. This function feeds the data character by character to the parsers, and then notifies the Scheme side of the new output on the standard channels and on the channels declared with :handler:
read (LINK_ERR);
connection_notify (this, "error", tm_err->get ("error"));
read (LINK_OUT);
connection_notify (this, "output", tm_out->get ("output"));
connection_notify (this, "prompt", tm_out->get ("prompt"));
connection_notify (this, "input", tm_out->get ("input")); |
Each of these calls invokes the Scheme function (connection-notify lan ses channel tree), which forwards the tree to the notify call-back of the pending request (for sessions: session-notify, which inserts the output, error output, prompt or default input into the session). Changes of the status are reported through connection-notify-status: status 2 (waiting for input) means that the current request is complete and the next one is started by plugin-next; status 0 means that the application died, in which case all pending requests are cancelled.
The Interrupt execution entry of the session menus (also available as an icon) calls plugin-interrupt, which sends SIGINT to the process group of the application (this is not implemented under Windows) and cancels the pending requests. The Close session entry calls plugin-stop, which sends SIGTERM to the process group, followed by SIGKILL two seconds later.
The following control characters are defined in
System/Link/tm_link.hpp
:
| Name | Code | Meaning |
| DATA_ABORT | 1 | discard the verbatim text of the current block |
| DATA_BEGIN | 2 | start a block |
| DATA_END | 5 | end a block |
| DATA_COMMAND | 16 | prefix of special commands sent to the application |
| DATA_ESCAPE | 27 | take the next character literally |
All output of the application is structured in blocks of the form DATA_BEGIN format: message DATA_END (without the spaces) or DATA_BEGIN channel# message DATA_END. Blocks may be nested. The parser texmacs_input_rep::put maintains a stack of (format, channel) pairs; as soon as the DATA_END which closes the outermost block has been read, the application is considered to be waiting for input. Characters outside any block are interpreted in the verbatim format on the default channel. A DATA_ESCAPE character causes the next character to be taken literally, which allows to use the control characters inside messages. A DATA_ABORT character at the very beginning of a verbatim or utf8 block suppresses the verbatim text of that block; according to a comment in the source code, this allows tab-completion with a naive read-eval loop which echoes its input.
The format of a block determines how its message is converted into a TeXmacs tree (see texmacs_input_rep::get_mode and the various *_flush methods in
Data/Convert/Generic/input.cpp
):
Plain text, converted with verbatim_to_tree using automatic detection of the encoding. The text is flushed at each newline, which allows for gradual output. Blocks in other formats may be nested inside a verbatim block.
Like verbatim, but the text is explicitly converted from UTF-8. This is the format used by flush_verbatim in the tmpy Python package.
A LaTeX snippet, converted using the latex-snippet converter. Use $…$ for formulas. The text is flushed at empty lines.
An HTML snippet, converted using the html-snippet converter and wrapped into an html-text tag.
A TeXmacs tree in Scheme syntax, such as (frac "a" "b"). This is also the format of the answers to special commands (tab-completion, input-done?).
A mathematical expression in prefix Scheme notation, such as (+ (* 2 x) 1), which is converted into presentation markup by cas->stree (
utils/cas/cas-out.scm
) and inserted in math mode.
Encapsulated PostScript, inserted as an image. The message may start with lines width=w and height=h; the default width is given by the preference plugins:embedded postscript width (0.7par by default).
The name of an image file, optionally followed by parameters, as in /tmp/plot.png?width=400px&height=300px. Supported suffixes are png, eps, pdf and svg; the width may be given in pt, px or par and the height in pt, px or pag. The contents of the file are embedded in the document. Errors (such as a missing file) are reported as verbatim output.
A Scheme command, which is evaluated as (begin message) as soon as the block is closed. See sending commands to TeXmacs.
Legacy syntax for switching channels: DATA_BEGIN channel:prompt DATA_END redirects the remainder of the enclosing block to the prompt channel. It is equivalent to, but less convenient than, the prompt# syntax.
If format is a data format known to TeXmacs ((format? format)), then the message is converted using the converter from format-snippet to texmacs-tree. This allows plug-ins to emit output in formats which they define themselves (see below).
Blocks in an unknown format are treated as verbatim. The formats cmdline-name and request-name are used internally for the :cmdline and :request connection types.
The channel of a block determines where its output goes. The channels which are understood by sessions are output (the default for the standard output), prompt (the prompt for the next input), input (a default value for the next input) and error. All output on the standard error of the application goes to the error channel and is displayed as error output (in an errput tag); it may again be structured using DATA_BEGIN-DATA_END blocks, as done by flush_err in
tmpy/protocol.py
. Blocks on other channels are only delivered if a handler has been declared with the :handler option; notice that the error channel of the standard output is not displayed unless a handler is declared.
Before being sent to the application, the input tree is converted to a string by (plugin-serialize lan t) (in
plugin-cmd.scm
), which calls the serializer declared with :serializer, or verbatim-serialize by default. The following building blocks are available for custom serializers:
Remove a document with a single child and convert math content into a string using the mathematical input converters of the plug-in lan.
Apply pre-serialize, convert the result to plain text using texmacs->code (in the locale charset), replace newlines and tabs by spaces, remove all other control characters and append a newline. In particular, multi-line input is sent as a single line; a plug-in which needs to preserve newlines must provide its own serializer (the python plug-in, for instance, sends the input with its newlines followed by a line <EOF>).
Send the input as a DATA_BEGIN verbatim: … DATA_END block, with the control characters escaped (escape-generic). Newlines are preserved.
Some requests are not ordinary input, but commands for the application, such as tab-completion requests. The string of such a command is formatted by (format-command lan s), which calls the function declared with :commander, or by default prefixes the string with DATA_COMMAND and appends a newline. The Scheme function (plugin-command lan ses cmd return opts) sends such a command asynchronously and passes the answer (usually a tree in the scheme format) to the call-back return. Two commands are currently sent by TeXmacs:
Sent by kbd-variant (the ⇥ key) in a session of a plug-in with :tab-completion. The string is computed by edit_interface_rep::session_complete_command in
Edit/Interface/edit_complete.cpp
, using verbatim-serialize (not the custom serializer of the plug-in). The answer should be a tuple (tuple root completion-1 …), which is passed to custom-complete. See tab-completion.
Sent by kbd-enter when the user presses ↩ in a session of a plug-in with :test-input-done. The input is serialized with the serializer of the plug-in. The answer #f inserts a newline, any other answer evaluates the input.
When mathematical input is enabled in a session (Mathematical input in the input options menu of the session, which calls toggle-session-math-input; this entry is only shown for plug-ins with input converters), the input field is a formula and the option :math-input is passed to session-feed. The function plugin-preprocess then converts the formula into a string using (plugin-math-input (list 'tuple lan formula)), provided that the plug-in declared input converters. The default for new sessions can be set with the boolean preference lan-math-input (and similarly lan-text-input for textual input), as read by session-math-input? and session-text-input?.
Input converters are declared with plugin-input-converters (see mathematical and customized input) and are usually put in a separate module which is loaded on demand:
(when (supports-maxima?)
(lazy-input-converter (maxima-input) maxima)) |
Rules which are not defined by the plug-in fall back to the rules of the generic converter at the end of
utils/plugins/plugin-convert.scm
, which for instance rewrites fractions as (a/b), <alpha> as alpha and matrices as [a, b; c, d].
Evaluate t (a TeXmacs tree in Scheme form) using the session session of the plug-in name, and return the output in Scheme form. The connection is started if necessary. This function is synchronous: it calls the C++ function connection_eval, which blocks until the application is waiting for input again. The output is simplified with plugin-output-simplify; the option :math-input enables the conversion of mathematical input. The function is defined in the module (utils plugins plugin-eval).
(silent-feed lan ses in return opts)
Queue an asynchronous evaluation of in without any visible session. For silent-feed, the call-back return receives a pair of the output and the error output, or one of the keywords :dead and :interrupted. For silent-feed*, it receives a single tree: the output, the error output in red, or a script-dead or script-interrupted tag.
A plug-in configured with :scripts can be selected as the scripting language of a document (Document\(\rightarrow\)Scripts), which sets the environment variable prog-scripts. Formulas or selections can then be evaluated in place (script-eval), numerically evaluated (script-approx, which inserts the function set with plugin-approx-command-set!), or turned into executable fields (script-input). All these operations end up in (script-eval-at where lan session in . opts) and script-feed in
dynamic/scripts-edit.scm
, which use silent-feed* and replace the tree where by the result. The rendering of script-input fields can be customized per language through a macro lan-script-input.
A Scheme function which is declared with (:secure #t) can be called from the extern primitive in style files. By combining this with plugin-eval, a plug-in can provide new markup whose rendering is computed by the extern application. See the secure plug-in in the section on background evaluations.
The following hooks are provided for plug-ins:
This menu is declared empty in
texmacs/menus/main-menu.scm
and linked into the main menu bar. A plug-in adds a top-level menu using a conditional binding, as done by the maxima plug-in:
(menu-bind plugin-menu
(:require (or (in-maxima?) (and (not-in-session?) (maxima-scripts?))))
(=> "Maxima" (link maxima-menu))) |
Icons which are displayed in the help part of the toolbar inside sessions (see
plugins/python/progs/python-menus.scm
).
This menu is also declared in
main-menu.scm
, but it is not linked into any toolbar in the current version.
The contents of the preferences of the plug-in, for plug-ins configured with :preferences.
Keyboard shortcuts which are specific to a plug-in are defined with kbd-map and the automatically defined modes, for instance (kbd-map (:mode in-maxima?) (:mode in-math?) ("$" "$")).
When a session or a script input field for the language lan is inserted, the style package lan.ts is automatically added to the document, provided that it can be found in $TEXMACS_STYLE_PATH (for instance in lan/packages/session/lan.ts). The generic session markup in
packages/compute/session.ts
dispatches on the current programming language: if the macros lan-session, lan-input, lan-output, lan-errput or lan-textput are defined, they are used instead of generic-session, generic-input, etc. The colors of prompts and inputs are controlled by the environment variables generic-prompt-color and generic-input-color, which a package may redefine. The default prompt, as long as the application did not send one, is Lan] (plugin-prompt).
A plug-in may also extend the set of file formats of TeXmacs, for instance in order to import and export source files of its language. A format is declared with define-format and the conversions with converter (see
kernel/texmacs/tm-convert.scm
). For example,
plugins/python/progs/python-format.scm
contains
(texmacs-module (python-format))
(define-format python
(:name "Python source code")
(:suffix "py"))
(converter texmacs-tree python-document
(:function texmacs->python))
(converter python-snippet texmacs-tree
(:function python-snippet->texmacs)) |
together with the corresponding python-document and texmacs-tree-to-python-snippet converters. Such modules are loaded lazily with (lazy-format (module) format …), which imports the module after two seconds of idle time or as soon as the list of formats is needed. For the plug-ins which are shipped with TeXmacs, these declarations are made in
init-texmacs.scm
; a third-party plug-in can put the lazy-format declaration in its own initialization file. Once a format fm with a converter from fm-snippet to texmacs-tree is defined, the application may also use fm as an output format in the pipe protocol.
TeXmacs can also run plug-ins which are installed on another machine, through ssh. The command (detect-remote-plugins server), available through Insert\(\rightarrow\)Session\(\rightarrow\)Remote, runs
ssh server "texmacs -s -x \"(write-local-plugin-info)\" -q" |
on the remote server. The function write-local-plugin-info writes the remote PATH, the list of pipe launchers and the session and scripting language tables. This information is stored in $TEXMACS_HOME_PATH/system/remote-plugins.scm, and each remote launcher cmd becomes a local launcher of the form ssh server "export PATH=…; cmd" for the variant server/variant. Only pipe launchers can be used remotely. The remote environment has to be prepared in the ~/.bashrc of the remote account.
Run the helper application by hand in a terminal, with exactly the command given to :launch, and check its output. The control characters DATA_BEGIN and DATA_END are usually displayed as ^B and ^E. Make sure that the output is flushed after each DATA_END; otherwise TeXmacs waits forever.
Start TeXmacs with the option -debug-io, or enable Debug\(\rightarrow\)io (the Debug menu appears after enabling Tools\(\rightarrow\)Debugging tool). All data exchanged with pipes is then printed on the terminal, with the control characters displayed as [BEGIN], [END], [ESCAPE], [COMMAND] and [ABORT], and the input preceded by [INPUT]. With Debug\(\rightarrow\)auto, the launch commands and the results of dynamic linking are printed as well.
If a plug-in is not detected, check the :require condition in a Scheme session, for instance (url-exists-in-path? "maxima"), check (supports-maxima?) and use Tools\(\rightarrow\)Update\(\rightarrow\)Plugins (or remove $TEXMACS_HOME_PATH/system/cache/plugin_cache.scm) to force a new detection. Remember that the bin directory of a plug-in is only added to the PATH if it existed at startup.
Errors in the initialization file and unknown configuration options are reported in the terminal from which TeXmacs was started; unknown options produce the message warning: unsupported tm-configure option.
Use the standard error of the application for diagnostics: it is displayed as error output in the session, and does not interfere with the DATA_BEGIN-DATA_END structure of the standard output.
Remember that the initialization of plug-ins is lazy: code in init-myplugin.scm is only executed about one second after startup, or earlier if lazy-plugin-force is called.
The following peculiarities of the current implementation are worth knowing when writing a plug-in:
The :socket option is accepted by plugin-configure, but connection_start does not create socket links, so it is not functional.
In connection_rep::start, the startup output of a dynamic link is only processed immediately when the plug-in is called dynlink (the test is on the name of the plug-in, not on the type of the link).
Dynamic linking requires TM_DYNAMIC_LINKING to be defined at compile time. The autotools configuration defines it (as dlopen) through
misc/m4/dlopen.m4
; otherwise symbol_install returns "Dynamic linking not implemented".
The :prioritary option is read from the plug-in cache before the cache has been loaded, and therefore seems to have no effect.
Plug-ins in /etc/TeXmacs/plugins and /usr/share/TeXmacs/plugins are listed, but their initialization files are not loaded (see above).