sage-shell-mode
sage-shell-mode copied to clipboard
Using %cython directive
I can't get sage-shell-mode to accept %cython magic markers. The same code that copy-paste works in the IPython Sage shell gives the following error when C-c C-r'ing the code inside Emacs:
sage: load('/tmp/sage_shell_mode14470ZZ2/sage_shell_mode_temp.sage')
File "<string>", line 2
%%cython
^
SyntaxError: invalid syntax
Is there any way to make %%cython work?
Thanks for report. I think it is possible to implement such a command for any magic function.
You can now use %%cython when evaluating regions or buffers. But it seems that %%cython must be at the top line of the region or the buffer. Otherwise it will raise an error. It may be a bug of get_ipython().run_cell or %%cython.
For example, evaluating the following code with C-c C-c raises an error. Without the first statement, it works fine.
a = 1
%%cython
def f(double x):
return x * x + x
The following also works fine.
%%cython
def f(double x):
return x * x + x
a = 1
By the way, you can also use other magic functions.
This is a great addition - thanks!