Skip to content

A new TeXmacs plugin for Mathematica utilizing new version of WSTP interface

License

Notifications You must be signed in to change notification settings

hammerfunctor/tm-mathematica

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Mathematica plugin for TeXmacs

This project provides the functionality to use GNU TeXmacs as the frontend of Wolfram language.

./demo.png

Usage

To use this package, you need to confirm executable wolframscript or wolfram locates in one of you system search paths. The disired directory on windows may be something like C:\Program Files\Wolfram Research\Mathematica\13.0\ for Mathematica or C:\Program Files\Wolfram Research\WolframScript\ for WolframEngine (enable the extra component wolframscript when installing WolframEngine). When you have the directory, add it to environment variable Path on Windows or shell variable PATH on *nix.

After that, put this package in your plugin directory inside TeXmacs home path and name it as mma. By default it should be $HOME/.TeXmacs/plugins on Linux and macos, and %AppData%/Roaming/TeXmacs/plugins on windows. You can either git clone or download a zip packed directory from the github interface.

git

If you use git

For Linux/macos:

cd $HOME/.TeXmacs/plugins #
git clone https://github.com/hammerfunctor/tm-mathematica mma

For windows

cd %AppData%/Roaming/TeXmacs/plugins
git clone https://github.com/hammerfunctor/tm-mathematica mma
cd mma && git checkout wolframscript

zip download

Download this package as a zip file, put it in the the directory just mentioned, change the name of dir to mma, and you are done.

Troubleshooting

On windows once you properly set the environment variable Path, TeXmacs will correctly recognize this plugin.

For macos and Linux the PATH TeXmacs is aware of is a little tricky. When you login, your user login-shell init file, $HOME/.zprofile, $HOME/.profile or $HOME/.bash_profile depend on your desktop manager and login shell, should be executed.

On Linux just set your PATH variable in one of that respected by your system, and everything is okay.

On macos TeXmacs is aware of the existence of $HOME/.zprofile if you start it from terminal, while not if you run texmacs from spotlight search. One workaround is to link /usr/local/bin/wolframscript to =/path/to/wolframscript, which is always in PATH.

UPDATE

2023/08/12

wolframscript now merged into main, and original main written in cpp is now left in the branch cpp.

2023/08/01

  1. Breaking change: Magic line style changed from
    % -width 400
        

    to

    (** width:400px **)
        

    Note that you need to specify px if what you want is in number of pixels.

  2. You can now use % or %n to refer to previous output. As usual, output prompt, whose index is the same as the input prompt index, won’t be printed when there’s a single output.

2023/07/30

Adapt mogan.

2023/03/05

Add a more consistent code dumping script bin/tmdumpcode1 using TeXmacs scheme. Look into and use it at your own risk.

2023/02/10

Introduced some syntax highlight Elements. If you want to enable it, add to you init file my-init-texmacs.scm:

(lazy-format (mma-format) mma)

Formula input is still buggy as of now. I’m too busy to get some time fixing it. If you have trouble with that, just don’t use it.

2022/09/22

You can now enter math formulus in a mathematica session, type $ followed by tab to enter math environment! This is especially useful when you need to manually do some manipulations on the results returned by mathematica, or to copy from somewhere else within TeXmacs. At present only a limited set of math formulus can be remapped to mathematica functions. Look into mw-converter.scm for details. Since all this function does is to map string snippet, it’s hard to define a standard remap rules set for everyone. Anyway, you can hack and tailor it to your own use case.

NOTE: You need to take care of what you type in a math environment. Basically the process is: math env -> texmacs routine -> string match and replace, so use math env only for formulus if you have little knowledge on TeXmacs internals and don’t want to make your hands dirty.

2022/09/04

Your codes now can be indented automatically.

2021/12/06

Outputname prefix like Out[12]= now will not be displayed only when there is one single return, which is really useful for that wrapped in a executable fold, e.g. a figure in the demo.

Added a python script to dump all codes within mma sessions of a .tm file to a .m file. This will be helpful if you want to collect all codes for some specific use case. Run:

# if path of this script is already added to $PATH
# use an alias or different link name if you like
tmdumpcode <path to .tm file like rep.tm> [<target .m file like rep-out.m>]

Then rep-out.m (or rep.m if no target is specified) will appear in your current directory.

⚠️NOTE: This will override your target file. Be careful!

2021/11/25

One night I wanted to neither read books nor sleep, then I rewrote this project. Now % like that in notebook frontend is supported, and, the logic of format and inter-communication is clarified. (Though it’s possible to write %12, I personally recommend you not to do like this, since each time codes are rerun, indices will most probably change.)

Have fun!

About

A new TeXmacs plugin for Mathematica utilizing new version of WSTP interface

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published