This package adds support for working with Macaulay2 source code in Org Mode.
#+BEGIN_SRC M2
R = QQ[x, y, z, w]
monomialCurveIdeal(R, {1, 2, 3})
#+END_SRC
#+RESULTS:
: 2 2
: ideal (z - y*w, y*z - x*w, y - x*z)
There are several options for installing ob-M2:
In a terminal:
git clone https://github.com/d-torrance/ob-M2
cd ob-M2
make install
(quelpa '(ob-M2 :repo "d-torrance/ob-M2" :fetcher github))
(straight-use-package '(ob-M2 :type git :host github :repo "d-torrance/ob-M2"))
Add the following to your .emacs
or init.el
. The ...
indicates any other pairs of the form (<lang> . t)
specifying languages you wish to load.
(org-babel-do-load-languages
'org-babel-load-languages
'((M2 . t)
...))
Open a file with the .org
file extension in Emacs and type C-c C-, s M2
to
begin a new Macaulay2 source code block. Then start coding! Type C-c C-c
to evaluate.
For complete documentation, see the Working with Source Code section of the Org Mode manual.
To generate graphics, specify the file
type and graphics
format along
with a :file
header argument. Then in your Macaulay2 code, call show (or
a function that calls it like displayGraph). The resulting image will be
generated with the desired filename. Note that the convert
utility from
ImageMagick must be present for this to work.
#+BEGIN_SRC M2 :results file graphics :file barbell.png
needsPackage "Graphs"
displayGraph barbellGraph 3
#+END_SRC
#+RESULTS
[[file:barbell.png]]
Initially, a link to the image file will appear, but it may be
displayed in the buffer by calling M-x org-toggle-inline-images
.