A Scheme session outside of TeXmacs document

My intention is to have an REPL of TeXmacs scheme outside of the session system currently implemented. While the session scheme is great in learning TeXmacs, I find it a bit hard to test out my code for navigating and editing TeXmacs document, due to the output of the evaluation being dumped back onto the current document. For instance, if I want to learn how “(traverse-right)” work in the editor, and I use the Scheme session, it doesn’t help me when I evaluate the expression, since it moves to the next prompt.

My proposed use case of such REPL is to have it open along side TeXmacs, which can have a document open. Let’s say I finish writing my code, I can send the expression into the REPL and see the document changes in real time. Evaluating “(buffer-tree)” just gets a copy of the document, it doesn’t help me understand the underlying structure of a certain document.

It seems easy to implement, but I have spent some time with no luck. :frowning: One notable attempt is to implement a REPL in init-texmacs.scm. While I can evaluate some expressions, it blocks the program from completely loading.

So just pop in here and see if anyone has some good ideas/pointers for me. :slight_smile:

Thanks.

How about two documents windows, one test document and one document with a Scheme session? In the Scheme session you can manipulate the buffer in the other window. You can get a list of buffers with ‘(buffer-list)’ ( see Chap. 4 of the TeXmacs Scheme Developer Guide). Is that of any help with your use case?

This does sounds like an easy alternative for plebs like myself :slight_smile: Thanks!

Do you happen to know where is a collection of editing/buffer related Scheme documentation? Examples of code would be nice.

Can I operated on another buffer while I’m on the other buffer?

Glad you found it useful!

My main source for info on this is “Help->Full Manuals->Scheme Developers Guide”.

I guess the command you want to look at first are (buffer-list) and (buffer-get-body). You could do something like

(tree->stree (buffer-get-body (fifth (buffer-list))))

Where you’ll have to change fifth to whatever buffer on the list you want to inspect.

Besides that I also find it useful to start TeXmacs from the terminal and use “Debug->Execute->Execute Scheme Expression” to do some quick one-command debugging with (display* (...)). Also the “Debug->Status->Tree” can be useful to quickly inspect the tree.

HTH

1 Like

Yes, scheme does not care in which buffer you are in. In the documentation you find some uses of scheme to modify the document tree. Also if you want to know all the functions you can use and which are implemented in scheme you can give a look at the scheme files in src/Scheme/Glue.

1 Like