Standard utilities

Besides the basic concepts from the previous sections, which underly the scheme API for TeXmacs, the Scheme kernel implements several other utilities and language extensions. In this section, we will briefly sketch some of them on hand of examples. Further details can be found in the chapter about TeXmacs extensions to Scheme and utilities.

Regular expressions

TeXmacs implements the routines match? and select for matching regular expressions and selecting subexpressions along a “path”. These routines both work for the content type. For instance, in order to search all expressions of the form

a
1 + sqrt (b)

in the current buffer, where a and b are general expressions, one may use the following Scheme command:

scheme]

(select (buffer-tree) '(:* (:match (frac :%1 (concat "1+" (sqrt :%1))))))

Dialogues

TeXmacs supports several commands for asynchronous evaluation of scheme commands and interactive dialogues with the user. In general, asynchroneous instructions have to be encapsulated inside a “dialogue block”. For instance, when executing the following scheme command, you will be prompted for two numbers, whose product will be displayed in the footer:

scheme]

(dialogue

(let* ((a (string->number (dialogue-ask "First number:")))

(b (string->number (dialogue-ask "Second number:"))))

(set-message (number->string (* a b)) "product")))

User preferences

When writing a plug-in, you may wish to define some new user preferences. This can be done using the define-preferences command, which adds a list of user preferences, together with their default values and a call-back routine. The call-back routine is called whenever you change the corresponding preference. For instance:

(define-preferences

("Gnu's hair color" "brown" notify-gnu-hair-change)

("Snail's cruising speed" "1mm/sec" notify-Achilles))

Preferences can be set, reset and read using set-preference, reset-preference and get-preference.

New data formats and converters

New data formats and converters can be declared using the define-format and converter instructions. When a format can be converted from or into TeXmacs, then it will automatically appear into the FileExport and FileImport menus. Similarly, when a format can be converted to Postscript, then it also becomes a valid format for images. TeXmacs also attempts to combine explictly declared converters into new ones.

Typically, the declaration of a new format and a converter would look like:

(define-format blablah

(:name "Blablah")

(:suffix "bla"))

(converter blablah-file latex-file

(:require (url-exists-in-path? "bla2tex"))

(:shell "bla2tex" from ">" to))

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