Closed martibosch closed 9 months ago
Puzzling. code-cells-eval
sends the whole cell, including the comment header # %%
, to the REPL. Could that be the cause of the trouble? In this case one would have to argue that this is not a bug in Jupyter...
I suppose that including the comment header is indeed the cause of the trouble, because when I select the whole cell including the commend header and run it using jupyter-eval-region
, I get the same error.
I therefore do not think that it is a bug in Jupyter as cell magic is supposed to be at the first line of the cell (regardless of comments). In any case, it is not a big deal and for other users encountering this issue, using the jupyter-eval-region
approach as workaround is quite straightforward.
I guess I could add an option to modify this behavior, or even hard-code it. But I need to think of possible side-effects.
Consider the following notebook with an associated emacs-jupyter REPL:
running
code-cells-eval
in the first cell raises a Jupyter error "UsageError: Line magic function%%timeit
not found.". Instead, manually selecting the four lines of the first cell and runningjupyter-eval-region
runs correctly, giving the execution time in a buffer named*jupyter-output*
.The second cell runs properly (createing two buffers, one named
*jupyter-result*
with the result and another named*jupyter-output*
with the measured execution time).How can this be fixed? I suppose that it is an issue of how code-cells sends the cell code to emacs-jupyter given that
jupyter-eval-region
works properly.Thank you in advance. Best, Martí