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).