/ob-magma

Support for magma in org-babel

Primary LanguageEmacs Lisp

Warning

This package is by no means ready for production use. I have stopped working on it in the spring of 2015, so I may not be able to provide support. But please, if you test it and encounter issues, feel free to post them here for reference.

If someone is wishing to pursue developing this package, I will be glad to help to my best capacity.

Magma in org-babel

Basics

This package provides support for magma evaluation with org-babel. Evaluation is made in a unique magma session, explicit naming of sessions is possible.

Results type can be either ‘output or ‘value, in which case magma tries to determine whether the output is a table or not. If your output is a sequence and you do not wish to format it as a table, use ‘output for this code block.

Tne parameter :magma-eval t causes the block to be enclosed in an eval form. The output value is given by the return statement. At the moment, nothing is done to suppress other forms of output. This evaluation method corresponds to =’value= for most other modes, but due to limits with magma eval (for example, no side effect is possible), making it the default would be counter-intuitive.

This package is intended to be used with the magma-mode available here, but in theory, it could work with any magma-mode providing a function magma-run (&optional session) creating a magma interactive buffer and returning it. The function may disregard the session argument, in which case the :session parameter of org will have no effect.

Examples

(Please see the readme in raw org form for the results of the examples)

Results are handled as string by default:

print(3+3);
print(x+3);

If the result is a sequence, it is returned as a org table.

print([[1,2,3],[4,5,6],[7,8,9]]);

If this is unwanted, use the :results output parameter.

print([[1,2,3],[4,5,6],[7,8,9]]);

A special evaluation method is given by the :eval parameter. In this setting, all code is wrapped in an eval form, and evaluated. The code block should have a return statement and avoid printing overall (this will be fixed in the future).

x := 3;
y := 4;
return x + y;

Finally, session-based evaluation is also supported:

x := 3;
print x;
x := 4;
print x;
print x;