Ask Your Question
1

sage-shell-mode positions cursor incorrectly

asked 2020-12-24 16:39:33 +0200

bthomas gravatar image

Hi

After clean apt-get install of Sage 9.0 on Ubuntu 20.04 and cloning the latest sage-shell-mode git repository I find that running sage within Emacs 26.3 results in the prompt being positioned to the far right of the screen with preceding spaces. After each command the cursor is positioned to the far right of the screen. I have filed a bug report (issue 56). I would be grateful if anyone is familiar with the problem, and could point me to any known work around.

The problem is reproducible with a bare minimum .emacs file shown below


;; Add local elisp directory and sub-directories to load-path
(let ((default-directory  "~/.elisp/"))
    (normal-top-level-add-subdirs-to-load-path))
;;-------------------------------------------------------------------
;; Sagemath mode
(require 'sage-shell-mode)
(setq sage-shell:use-prompt-toolkit t)
(setq sage-shell:sage-root "/usr/share/sagemath")
(setq sage-shell:sage-executable "/usr/bin/sage")
;; Run SageMath by M-x run-sage instead of M-x sage-shell:run-sage
(sage-shell:define-alias)
;; Turn on eldoc-mode in Sage terminal and in Sage source files
(add-hook 'sage-shell-mode-hook #'eldoc-mode)
(add-hook 'sage-shell:sage-mode-hook #'eldoc-mode)
;; Enable inline plots and LaTeX preview
(require 'sage-shell-view)
(setq sage-shell-view-default-commands 'output)
(setq sage-shell-view-default-commands 'plot)
(add-hook 'sage-shell-after-prompt-hook #'sage-shell-view-mode)

regards Thomas

edit retag flag offensive close merge delete

Comments

Welcome to Ask Sage! Thank you for your question!

slelievre gravatar imageslelievre ( 2020-12-25 01:08:56 +0200 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2020-12-25 11:01:20 +0200

Emmanuel Charpentier gravatar image

updated 2020-12-26 09:32:00 +0200

Sage 9.2.beta8 broke sage-shell-mode compatibility with emacs by upgrading Ipython. A patch was created and proposed on a pull request on Aug 125, 2020. It has not yet been reviewed as of Dec 25, 2020.

In the interim, feel free to try my fork, source of the pull request.

EDIT : The patch just got merged in the main tree, and should diffuse to normal channels (i. e. MELPA) in due time.

Re-EDIT : The patched version has diffused to MELPA. My fork is no longer necessary.

HTH,

edit flag offensive delete link more

Comments

Thank you for your response.

I just pulled latest git master. Sage version 9.0 does not seem to support "simple-prompt". So after setting (setq sage-shell::sage-simple-prompt nil) and executing M-x run-sage, I find the problem still occurs. Although looks like with a few less spaces.

bthomas gravatar imagebthomas ( 2020-12-26 00:38:14 +0200 )edit

By pulling the latest git master, you mean of sage-shell-mode, right?

Try using a more recent Sage version? You can easily get Sage 9.2 via Conda or Docker, or by downloading binaries for Ubuntu 20.04 from the Linux download page on the Sage website..

slelievre gravatar imageslelievre ( 2020-12-26 01:59:40 +0200 )edit

Sage version 9.0 does not seem to support "simple-prompt"

This is, IIRC cared for in the initialization code

Anyway, upgrading to Sage > 9.1 is recommended, for much stronger reasons (Python 3....).

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2020-12-26 09:36:00 +0200 )edit

And, BTW :

I just pulled latest git master

My patch is in the simple prompt branch of my forked tree ; master is untouched (necessary to submit a PR through Github's baroque mechanisms...).

Again, this has now been merged in the master branch of the version distributed by MELPA.

HTH,

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2020-12-26 12:03:09 +0200 )edit
0

answered 2020-12-27 18:09:57 +0200

bthomas gravatar image

For whatever it is worth, I was able to find a work around on Ubuntu 20.04 using the prepackaged Sage 9.0. The trick is to follow the advice on issue 52 by editing the line exec sage-ipython "$@" -i in /usr/bin/sage and changing it to exec sage-ipython "$@" --simple-prompt -i . It is also necessary to add (setq sage-shell::sage-simple-prompt nil) to the .emacs file. All this was found to work with the latest sage-shell-mode version from its git repository that had Emmanuel Charpentier's patches merged in.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-12-24 16:39:33 +0200

Seen: 651 times

Last updated: Dec 27 '20