A partial implementation of `cl-letf`

Hi, I’m sharing a convenient and non-intrusive way to hack scheme part of TeXmacs. What I’m trying to do here is to implement something like Emacs’ cl-letf that allow you to locally reload things. Due to the lack to setf mechanism, this can only be done partially. Specifically, one cannot modify places like

(setf (car x) 1)

From what I can tell this is impossible in scheme. I included two examples in a companion tm doc. One is to use it to print out arguments of specified functions like

(with-display-arguments ((a) (b mod-b))
  (some-procedures))

when those procedures are executed, arguments received by a and unexported function of b within module mod-b will be printed in the console, if you start TeXmacs from a console.
In the other example, I showed how to advice TeXmacs not to export to LaTeX some constructs, which is initially what I wanted to implement. This is especially useful when you want to keep something as note to yourself while rest of the document sent to publisher. I feel such a macro would be very useful to young hackers who would like to explore internals of TeXmacs and that’s why I’m sharing here.

I made it into tm-forge and sent a PR to the main repo. Before it’s accepted you can try it in my own one https://github.com/hammerfunctor/tm-forge/tree/main. Feel free to try and comment on it and use it to develop other fun stuffs. At some point we could even make it upstream.

1 Like