1

I wanted to use sagemath straight in emacs instead of having a terminal open. I tried to use a shell (or eshell for that matters) in emacs and launch sage there, but every time I input a command, the ouput repeats this and then displays the result. Something like:

┌────────────────────────────────────────────────────────────────────┐ │ SageMath version 8.1, Release Date: 2017-12-07 │ │ Type "notebook()" for the browser-based notebook interface. │ │ Type "help()" for help. │ └────────────────────────────────────────────────────────────────────┘ sage: 2+2 sage: 2+2 4 sage: 

After a quick search on how to use sage in emacs, I found the neat sage-shell-mode. Installed it using MELPA (as recommended), but the problem is the same. I have no idea where it comes from and how to fix it.

N.B. when I use emacs shell (or eshell), I have no problem. When I use sage in a terminal, I have no problem. Only when I use sage in emacs (in a shell or using sage-shell-mode) I got the issue.

I'm using Emacs 25.2.2 and SageMath 8.1

1 Answer 1

0

This is a problem of cursor positioning - it looks identical to the problem encountered when running ipython5 as described here: Weird shell output when using IPython 5

Unfortunately, it does not appear that SageMath allows you to pass in the --simple-prompt argument.

The SageMath shell does work properly when it can set cursor position, and therefore works well using M-x term or M-x ansi-term, both of which provide terminal emulation.

Good news for the future: I found a PR awaiting merge in the python-prompt-toolkit repo that aims to fix this problem. Then all you will need to do is install from pip install or build from source, and set sage-shell:use-prompt-toolkit to t in the sage-shell-mode package.

4
  • M-x term is going to do it, even if I lose the possibility to move my cursor freely and copy/paste piece of code to another buffer... I can live like that for now Commented May 25, 2020 at 14:32
  • Expanded my answer after searching for a better solution - I was going to file an issue, but found that a real solution is already in the pipeline. Hopefully you will find it acceptable! Commented May 25, 2020 at 15:24
  • That's great, I'll definitely look into it and wait for the release! Commented May 25, 2020 at 16:45
  • Would you mind accepting my answer? Thanks! Commented May 25, 2020 at 17:43

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.