DEV Community

Valentin Boettcher
Valentin Boettcher

Posted on • Originally published at protagon.space on

Modern Python REPL in Emacs using VTerm

As alluded to in Poetry2Nix Development Flake with Matplotlib GTK Support, I’m currently in the process of getting my “new” python workflow up to speed. My second problem, after dependency and environment management, was that fancy REPLs like ipython or ptpython don’t jazz well with the standard comint based inferior python repl that comes with python-mode. One can basically only run ipython with the --simple-prompt flag which removes features like syntax-highlighting and auto-completion. Especially annoying is, that only the tkinter backend for matplotlib works in this mode.

The package elpy comes with some improvements, especially when it comes to sending part of a buffer to the repl, but it comes with all sorts of baggage that interfere with my emacs setup.

From my jolly Julia days I’m used to julia-vterm. This emacs package runs a Julia REPL using a full terminal emulator (emacs-libvterm). So in the pursuit of a nice hack, I M-x replace-string’d the word juliawith python and gave it a shot. Remarkably, the whole thing just worked without much tweaking and you can enjoy the result by checking out the GitHub repo.

The idea of extending the original julia-vterm package to support python as well is not without elegance. However, the code base is not too large and – owing to the differing sensibilities of the julia and python communities – the feature-set is likely to diverge in the future.

Figure 1: And this is the result!
Figure 1: And this is the result!

Top comments (0)