Developing Plugins for TeXmacs and Mogan

The question might be stupid since I am relatively new to Scheme, with my prior programming experience being limited to Matlab and Python in Visual Studio Code. Currently, I am working on a plugin to implement a feature discussed in this forum post: Algorithm2e for Texmacs, using TeXmacs as an IDE and testing the functionality by inserting the .scm files as plugins.

However, this development method proves to be challenging due to the lack of debugging tools and auto-complete functionality when using TeXmacs-specific functions. Is there any way to develop using tools like vscode? (As far as I know, I can get the auto-complete from vscode, but the debugging and the test still require TeXmacs.)

Moreover, I am concerned about the compatibility of the plugin with Mogan, given that Mogan and the original TeXmacs utilize different Scheme compilers.

We will release Mogan Code, in the very beginning, Mogan Code will be used to develop Mogan STEM Suite itself.

Moreover, I am concerned about the compatibility of the plugin with Mogan, given that Mogan and the original TeXmacs utilize different Scheme compilers.

Most of the time, the scheme usage of the plugin is very limited. It is more like for configuration. For example, th majority in the octave plugin is octave language (.m) itself. Because we are using different scheme interpreters, there are more effort to make it work for both Mogan and TeXmacs. There are tricks but it is not that hard.

For the plugin which you are developing, Algorithm2e, most code shoud be TeXmacs style language in .ts.

I think in this case you are referring to plugins that implement communication between LaTeX and another program, while @Jack_Li’s question is more general I think; TeXmacs packages which operate on the document may require extensive Scheme programming.

IMO a definitive solution could be if Mogan and TeXmacs become fully compatible from this point of view, but on the other hand compatibility between different implementations is a sticking point of Scheme and it might continue to come up one way and the other.

Because of this, a different definitive solution might be to adhere to the one of the standards in your programming; this is more limited than Guile but it should ensure that all Schemes read your program.

Maybe the right standard to adhere to is RSR5 the current standard is RSR7 I think, but guile 1.8, used by TeXmacs, might take RSR5 as a starting point … with all of this sentence under a big maybe because I need to document myself on all of the facts I state. But I want to post this now as I think the idea is worth considering, then we may change the details.

I cannot help with the debugging and the auto-complete for the TeXmacs-specific functions; for formatting Scheme I use emacs with paredit, and for auto-complete I have used something that depends on the irony package, but I do not have the details on hand as it is many months that I do not program in Scheme.

I think that it is worth investigating; I recall that I had to modify something in the configuration of the emacs packages to get the whole thing to work but again I do not recall the details. After a bit of work I had autocompletion for Scheme commands though. If you are interested I could try and dig out the websites where I found the information that helped me get my configuration working.

Yes, this is what I want. From my perspective. TeXmacs is more like Emacs than LaTeX. Thus, the plugin system should have the ability to do everything, at least the plugin system should behave like the plugin system on VS Code. Also, update your TeXmacs should not affect (or a very small affection) the behavior of the plugins. In this case, more developer will eager to develop plugins for TeXmacs (We can even have a Plugin Store). However, the current developing method I used to develop plugins for TeXmacs is more like editing .json files on VS Code rather than writing .el files on Emacs.

Are you using s7 scheme? I found it hard to install, there is no installation guide throughout its documentation. I just compiled the s7.c file manually to create s7.o and then use s7.o to compile repl. Then I need to apply repl on libc.scm to generate It took me the entire afternoon to do this. This is too hard for people not familiar with c or scheme language. Now, I can run the s7 repl, but I still don’t know how to integrate it into vscode and use the tools provided by the IDEs. I think we lack lots of tutorials and development tools (Especially for programming newbies like me). The scheme developer guide is out-dated and no instruction on the environment build is provided. Should I use TeXmacs itself as an IDE?

I am using Guile 2. I do not know VS code so I cannot help you to set it up as an IDE for Scheme: I use emacs in Linux together with

  • paredit for formatting the code automatically
  • geiser ( for interacting with Schemes (with the default configuration, and using only the ability to interact with different Schemes … which maybe emacs has in its default configuration)
  • some form of irony and company for autocompletion (which maybe geiser does … but I did not check); here I had to work a bit to get it working
  • flycheck, which I do not know if does anything that the others don’t

It is chaotic but works for me. I am going to answer your previous message in this thread, on plgins in TeXmacs, later.

Isn’t texmacs complied by Guile 1.8 or Guile 3 and mogan is complied by s7?

I use Guile 2 because it is the default Guile up to a few versions of Ubuntu ago. Now (23.04) there are both Guile 2 and 3 in the repositories, I do not know which is default and I do not know which is the first version of Ubuntu that has Guile 3.

When writing in Guile 2, I look at the manual of 1.8 to check whether what I am using works there. Or better, often I first test if the code works in TeXmacs, and if TeXmacs does not know a function that I used I check whether it exists in Guile 1.8

It is a ragtag way of working, I agree a more disciplined one would work better. On the other hand, the whole “Scheme world” is made up of pieces that have incompatibilities with each other; maybe this depends on the “Scheme society”, which loves experimentation.

Sorry about these questions, I am new to scheme. As far as I learned now, the simplest way to develop scheme is to install racket and the DrRacket IDE. As you mentioned here, it seems that I can use racket to write scheme code following some patterns so that the code can also be complied with s7?

I think so. You need to keep with you the s7 manual as you write. After a few weeks of practice I recognize what is Guile 1.8 and what is only Racket (complex forms are Racket) only. It may be the same for you for Racket and s7.

Do not use racket, because racket is not the scheme intepreter adopted by Mogan or TeXmacs.

This is not very useful to develop for TeXmacs/Mogan. Just run Mogan and open a Scheme shell, there you have a REPL in which you can develop interactively. Once you know what you want you save your program in a scheme file. See e.g. here where I develop some script to modify pages. There are other examples TeXmacs blog (

1 Like

We just talked about Scheme programming for Mogan hosted by @jingkaimori
The participates are @darcy and @tangdouer .
Here is the video record (In Chinese)

I have led @Jack_Li a bit astray with the description of how I program in Scheme.

He can improve a bit the smoothness of developing Scheme with TeXmacs/Mogan by

  • selecting in the Preferences, under Other, Program bracket matching and Automatic program brackets

  • realizing that TeXmacs does command completion (I use it and I had forgotten about it). Press tab after having input a few letters and TeXmacs cycles through completions. The list of possible completions does not appear in a pop up, but on the status bar at the bottom

On the other hand developing outside of TeXmacs helps when you want to modularize your code. I don’t think it is terribly bad if you use a Scheme different from the ones that are used in TeXmacs, if you are aware that you can use only constructs of Guile 1.8 or s7

I also think that it would be important to find a way to encourage more people to write plugins for TeXmacs. On this I think (and my opinion here may be quite different from the opinion of developers) that it is helpful that people see an easy way to publish and distribute their work—best, being quite independent from the developers’ team.

The current tm-forge goes in this direction, I think it would benefit by being linked to from the TeXmacs website. Perhaps after a while one can discuss further simplifications: I like the way the archives of contributions for popular programs look and work (by the way, I think @darcy is working on a plugin center) .