Undocumented internal macros in TeXmacs (wiki)

This post is devoted to a collection of undocumented TeXmacs internal macros, hopefully this will help the documentation of TeXmacs. The idea is to keep it around here as a wiki post (i.e. editable by everybody) and maybe at a later stage integrate these informations in the blog or directly improve the documentations.

  1. (render-footnote* sym nr body). src. Generate a footnote like

sym. body

where sym is the preceding symbol and body is the text of the footnote. It will generate a label whose name is concatenating “footnote-” and the value of nr, referring to the location of the footnote. We have, on the other hand, a label whose name is concatenating “footnr-” and the value of nr, to which the sym in the footnote refers. This label is used to back-refer the footnote (that is to say, where we need this footnote).

  1. (render-footnote nr body) src. Invoking render-footnote* with sym=nr, nr=nr and body=body.

(It would be interesting to document the following tags, in particular the whole locus support)

  1. locus
  2. id
  3. hard-id
  4. set-binding
3 Likes

Could this be a good post for “TeXmacs notes” to which people can contribute gradually?

Maybe it is useful to keep it here so that contribution is easier for everybody. At some point it could be converted in a blog post. (or a blog post can summarise and edit the content of this thread).

It seems possible for admins to turn posts into “Wiki posts” in Discourse:

It may make sense for a post like this, where several people could make incremental contributions.

1 Like

I’ve made a wiki out of the original post. Thanks @jeroen!

What I currently understand of the locus system is the following:

When a new locus is inserted (enable Tools->Linking tool, then Link->New locus), a locus element is inserted in the document. This locus has a unique id and a content tree, which can be manipulated.

You can see a list of loci by doing Link->Extract->Loci (created using tree-search on (buffer-tree)). Although the id is created uniquely, by copying these elements different loci with the same id can exist. Their contents need not be identical. Given a locus element, (locus-id t) will give the locus id as a string, where t is a TeXmacs tree.

If you have the id of a locus, you can get the tree of the corresponding element with (id->loci "...."), taking the id string as argument. Note that this really a sub-tree of the document tree, so it is useful to find, for example, certain elements containing a locus using with-innermost or tree-up and the like. The contents of the locus can be had with (id->trees "....").

Contents can also be manipulated with locus-set, e.g.

(locus-set "+nWR9oal1xAc6vbB" '(math (frac "1" "6")))

This command sets the contents of all loci with the given id.

There are more locus commands (locus-link-types, locus-insert-link, locus-link-follow, etc.), but I haven’t yet worked out how they function.

1 Like