1
0
Fork 0
This commit is contained in:
Joris van der Hoeven 2012-02-01 21:55:18 +00:00
parent 25d0edfc1a
commit c78c7f7e81
1 changed files with 37 additions and 30 deletions

View File

@ -1,4 +1,4 @@
<TeXmacs|1.0.6.10> <TeXmacs|1.0.7.14>
<style|tmdoc> <style|tmdoc>
@ -6,10 +6,10 @@
<tmdoc-title|Standard utilities> <tmdoc-title|Standard utilities>
Besides the basic concepts from the previous sections, which underly the Besides the basic concepts from the previous sections, which underly the
scheme API for <TeXmacs>, the <value|scheme> kernel implements several scheme API for <TeXmacs>, the <scheme> kernel implements several other
other utilities and language extensions. In this section, we will briefly utilities and language extensions. In this section, we will briefly sketch
sketch some of them on hand of examples. Further details can be found in some of them on hand of examples. Further details can be found in the
the chapter about <hlink|<TeXmacs> extensions to <value|scheme> and chapter about <hlink|<TeXmacs> extensions to <scheme> and
utilities|../utils/scheme-utils.en.tm>. utilities|../utils/scheme-utils.en.tm>.
<paragraph*|Regular expressions> <paragraph*|Regular expressions>
@ -23,39 +23,46 @@
<frac|<with|color|brown|a>|1+<sqrt|<with|color|brown|b>>> <frac|<with|color|brown|a>|1+<sqrt|<with|color|brown|b>>>
</equation*> </equation*>
in the current buffer, where <with|mode|math|<with|color|brown|a>> and in the current buffer, where <math|<with|color|brown|a>> and
<with|mode|math|<with|color|brown|b>> are general expressions, one may use <math|<with|color|brown|b>> are general expressions, one may use the
the following <value|scheme> command: following <scheme> command:
<with|prog-language|scheme|prog-session|default|<\session> <\session|scheme|default>
<\input|scheme] > <\input|scheme] >
(select (buffer-tree) '(:* (:match (frac :%1 (concat "1+" (sqrt (select (buffer-tree) '(:* (:match (frac :%1 (concat "1+" (sqrt
:%1)))))) :%1))))))
</input> </input>
</session>> </session>
<paragraph*|Dialogues> <paragraph*|Dialogues>
<TeXmacs> supports several commands for asynchronous evaluation of scheme <TeXmacs> supports several commands for interactive dialogues with the
commands and interactive dialogues with the user. In general, asynchroneous user. For instance, when executing the following scheme command, you will
instructions have to be encapsulated inside a ``<scm|dialogue> block''. For be prompted for two numbers, whose product will be displayed in the footer:
instance, when executing the following scheme command, you will be prompted
for two numbers, whose product will be displayed in the footer:
<\with|prog-language|scheme|prog-session|default> <\session|scheme|default>
<\session> <\input|Scheme] >
<\input|scheme] > (user-ask "First number:"
(dialogue
\ \ (let* ((a (string-\<gtr\>number (dialogue-ask "First number:"))) \ \ (lambda (a)
\ \ \ \ \ \ \ \ \ (b (string-\<gtr\>number (dialogue-ask "Second \ \ \ \ (user-ask "Second number:"
number:"))))
\ \ \ \ (set-message (number-\<gtr\>string (* a b)) "product"))) \ \ \ \ \ \ (lambda (b)
\ \ \ \ \ \ \ \ (set-message (number-\<gtr\>string (*
(string-\<gtr\>number a)
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (string-\<gtr\>number
b)))
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ "product")))))
</input>
<\input|Scheme] >
\;
</input> </input>
</session> </session>
</with>
<paragraph*|User preferences> <paragraph*|User preferences>
@ -65,13 +72,13 @@
call-back routine. The call-back routine is called whenever you change the call-back routine. The call-back routine is called whenever you change the
corresponding preference. For instance: corresponding preference. For instance:
<\scheme-fragment> <\scm-code>
(define-preferences (define-preferences
\ \ ("Gnu's hair color" "brown" notify-gnu-hair-change) \ \ ("Gnu's hair color" "brown" notify-gnu-hair-change)
\ \ ("Snail's cruising speed" "1mm/sec" notify-Achilles)) \ \ ("Snail's cruising speed" "1mm/sec" notify-Achilles))
</scheme-fragment> </scm-code>
Preferences can be set, reset and read using <scm|set-preference>, Preferences can be set, reset and read using <scm|set-preference>,
<scm|reset-preference> and <scm|get-preference>. <scm|reset-preference> and <scm|get-preference>.
@ -88,7 +95,7 @@
Typically, the declaration of a new format and a converter would look like: Typically, the declaration of a new format and a converter would look like:
<\scheme-fragment> <\scm-code>
(define-format blablah (define-format blablah
\ \ (:name "Blablah") \ \ (:name "Blablah")
@ -102,7 +109,7 @@
\ \ (:require (url-exists-in-path? "bla2tex")) \ \ (:require (url-exists-in-path? "bla2tex"))
\ \ (:shell "bla2tex" from "\<gtr\>" to)) \ \ (:shell "bla2tex" from "\<gtr\>" to))
</scheme-fragment> </scm-code>
<tmdoc-copyright|2005|Joris van der Hoeven> <tmdoc-copyright|2005|Joris van der Hoeven>