How the Texmacs Plugin System Works

Hi, I don’t know anything about Lisp, I know the basics of C. I’m trying to get the following code snippet to work, to replicate the same thing as the input, but it’s not happening.

#include <iostream>
#include <string>

#define DATA_END     ((char) 5)
#define DATA_BEGIN   ((char) 2)

using namespace std;

int main() {
	
    string entrada=" ";

    do {
		
        cout << DATA_BEGIN << entrada <<flush;
        cout << DATA_END << flush;
        
        cin >> entrada;
        
    } while (entrada != "s");

    cout << DATA_BEGIN<< "Programa finalizado." <<flush;
    cout << DATA_END;

    return 0;
}

I think I’ve already fixed my mistake; the initial variable can’t be empty.
So, I have another question: besides “latex” and “channel,” where can I find all the classes that define the input types and what they refer to?

The ones I know about are verbatim, utf8, command, scheme, latex, file, ps, html, math, bibtex, texmacs and any format that has a “parse-XXXX-snippet” function (this could be user-defined). I havent encountered channel. What does it do?

1 Like

I don’t know what “channel” does; I think I’ve seen it in a plugin output. I’m trying to get Cadabra to work; I guess it’s sufficient for that purpose.

The relevant code is in src/Data/Convert/Generic/input.cpp, in particular

int
texmacs_input_rep::get_mode (string s) {
  if (s == "verbatim")  return MODE_VERBATIM;
  if (s == "utf8")  return MODE_UTF8;
  if (s == "latex") return MODE_LATEX;
  if (s == "scheme") return MODE_SCHEME;
  if (s == "html")  return MODE_HTML;
  if (s == "ps")  return MODE_PS;
  if (s == "math")  return MODE_MATH;
  if (s == "channel")  return MODE_CHANNEL;
  if (s == "command")  return MODE_COMMAND;
  if (s == "file") return MODE_FILE;
  if (format_exists (s)) return MODE_XFORMAT;
  return MODE_VERBATIM;
}

where

bool
format_exists (string format) {
  return as_bool (call ("format?", format));
}

So the scheme function format? determines the presence of other formats. Check the file for more details on how the other modes are handled.

3 Likes

It seems channel was used earlier to send the plugin prompt. However, interestingly, there is also a :handler field to the plugin specification that seems to allow you to install custom channel handlers (see TeXmacs/examples/plugins/handler).

The Cadabra developer has re-introduced support for TexMacs. I’ve seen some bugs and I don’t really understand what’s wrong. When I enable the option to view input and output in the console, TexMacs doesn’t output anything.
And the following output isn’t displayed at all:

TeXmacs] debug-io, [INPUT]young_project_tensor(ex, modulo_monoterm=True);
TeXmacs] debug-io, <EOF>
TeXmacs] debug-io, [OUTPUT 1]
TeXmacs] debug-io, [OUTPUT 0][BEGIN]verbatim:[END]
TeXmacs] debug-io, 
TeXmacs] debug-io, ------------------------------------------------------------------------------
TeXmacs] debug-io, [OUTPUT 1]
TeXmacs] debug-io, [OUTPUT 0][BEGIN]latex:$\left(\frac{2}{3}W_{p q r s} - \frac{1}{3}W_{p s q r}+\frac{1}{3}W_{p r q s}\right) \left(\frac{2}{3}W_{p t r u}+\frac{1}{3}W_{p u r t}+\frac{1}{3}W_{p r t u}\right) \left(\frac{2}{3}W_{q w t v}+\frac{1}{3}W_{q v t w} - \frac{1}{3}W_{q t v w}\right) \left(\frac{2}{3}W_{s w u v}+\frac{1}{3}W_{s v u w} - \frac{1}{3}W_{s u v w}\right)-\left(\frac{2}{3}W_{p q r s} - \frac{1}{3}W_{p s q r}+\frac{1}{3}W_{p r q s}\right) \left(\frac{2}{3}W_{p q t u} - \frac{1}{3}W_{p u q t}+\frac{1}{3}W_{p t q u}\right) \left(\frac{2}{3}W_{r v t w}+\frac{1}{3}W_{r w t v}+\frac{1}{3}W_{r t v w}\right) \left(\frac{2}{3}W_{s v u w}+\frac{1}{3}W_{s w u v}+\frac{1}{3}W_{s u v w}\right)-\left(\frac{2}{3}W_{a b m n} - \frac{1}{3}W_{a n b m}+\frac{1}{3}W_{a m b n}\right) \left(\frac{2}{3}W_{b c n p} - \frac{1}{3}W_{b p c n}+\frac{1}{3}W_{b n c p}\right) \left(\frac{2}{3}W_{c d m s} - \frac{1}{3}W_{c s d m}+\frac{1}{3}W_{c m d s}\right) \left(\frac{2}{3}W_{a d p s} - \frac{1}{3}W_{a s d p}+\frac{1}{3}W_{a p d s}\right)+\frac{1}{4}\left(\frac{2}{3}W_{a b m n} - \frac{1}{3}W_{a n b m}+\frac{1}{3}W_{a m b n}\right) \left( - \frac{2}{3}W_{a b p s}+\frac{1}{3}W_{a s b p} - \frac{1}{3}W_{a p b s}\right) \left(\frac{2}{3}W_{c d m p} - \frac{1}{3}W_{c p d m}+\frac{1}{3}W_{c m d p}\right) \left( - \frac{2}{3}W_{c d n s}+\frac{1}{3}W_{c s d n} - \frac{1}{3}W_{c n d s}\right)$[END]

I’m using Linux, a development version of TeXMacs, the beta version I think.

I would like to make some changes to my local installation.