Standard utilities |
Besides the basic concepts from the previous sections, which underly
the scheme API for TeXmacs, the
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] |
(select (buffer-tree) '(:* (:match (frac :%1 (concat
"1+" (sqrt :%1))))))
|
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")))
|
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 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
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))