Some hints to get things started. I defined a document like this
<TeXmacs|2.1.1>
<style|generic>
<\body>
<\hide-preamble>
<assign|snippet|<\macro|lab|body>
[<arg|lab>] <hrule>
<arg|body>
</macro>>
</hide-preamble>
<\snippet|snip1>
<\theorem>
dska dkasnkd nask dnas nd knas klndlasn kld naslk ndl asnd naslkndl nas
<\equation*>
x<rsup|2>+y<rsup|2>\<leqslant\>2
</equation*>
</theorem>
</snippet>
<\snippet|snip2>
<\theorem>
There are infinitely many primes.
</theorem>
</snippet>
<\snippet|snip3>
<\theorem>
<math|\<pi\>> is irrational.
</theorem>
</snippet>
\;
</body>
<initial|<\collection>
</collection>>
which I called “snippets.tm”, then in a scheme session you can start to play with it. For example
(define snippets-url "/Users/mgubi/Desktop/snippets.tm")
(buffer-load snippets-url)
load the buffer from disk into TeXmacs’ memory. You can check that it is there:
(buffer-list)
Then you can convert it to a scheme expression by
(define t (tree->stree (buffer-get-body snippets-url)))
which gives the list
(document (hide-preamble (document (assign "snippet" (macro "lab" "body" (document (concat "[" (arg "lab") "] " (hrule)) (arg "body"))))))
(snippet "snip1" (document (theorem (document "dska dkasnkd nask dnas nd knas klndlasn kld naslk ndl asnd naslkndl nas" (equation* (document (concat "x" (rsup "2") "+y" (rsup "2") "<leqslant>2")))))))
(snippet "snip2" (document (theorem (document "There are infinitely many primes."))))
(snippet "snip3" (document (theorem (document (concat (math "<pi>") " is irrational."))))) "")
Now all you have to do is to look for the snippet you want, get the scheme expression for it and then put in your current document.
To learn how to use TeXMacs scheme I find useful to go around in the $TEXMACS_PATH/progs
directory and look for keywords like load-buffer
, etc… and look how things are done there, after a while you discover useful functions and then you try to do your own cooking in a scheme shell.