jupyter emacs
Table of Contents
1 Jupyter Emacs
This is my personal guide for setting up jupyter notebooks in org mode of doom emacs, which required some specific configuration.
You might not even need this!
org-babel
already exists to serve a lot of the same purpose! Org mode already has a built in way to excecute a lot of code. In the case of typescript
look into the emacs package ob-typescript
, see more information in org mode. It turns out, If you want to use the session
variable, ob-typescript
is not enough, and you will have to use jupyter, as discussed in this note.
1.1 installation
→ sudo pacman -S jupyter
In doom emacs, also install the package. for doom, edit ~/.doom.d/config.el
and add (package! jupyter)
then, ~./.emacs.d/bin/doom sync
1.1.1 add typescript kernel
You have to add a typescript kernel to jupyter notebooks if you want to work with typescript. After a little research, I decided on one called tslab
sudo npm install -g typescript sudo npm install -g tslab tslab install
now, you should be able to run the REPL with jupyter-run-repl
and choosing the typescript option. It start’s up a typescript kernel process in the background
you should now be able to see javascript and typescript with a $ jupyter kernelspec list
initially, you should be able to open REPLS with M-x jupyter-run-repl
, and at this point, have python, typescript, and javascript available to you.
1.2 Integrating with org mode
this is all a little bit trickier because of using DOOM emacs.
it shhould be really easy to get working according to this documentation: however, in doom, because of performance enhancer’s it get’s a little bit trickyer, even though it should be easier. also check this issue in doom for more info
first: turn on +jupyter
in init.el
of doom
I needed the following settings in my config.el
to get everything up and running:
it was important in my case that async was not included
(setq org-babel-default-header-args:jupyter-typescript '( (:session . "ts") (:kernel . "tslab"))) ;; this seems to add syntax-highlighting to jupyter-python and jupyter-typescript blocks (after! org-src (dolist (lang '(python typescript jupyter)) (cl-pushnew (cons (format "jupyter-%s" lang) lang) org-src-lang-modes :key #'car)) ;; (org-babel-jupyter-override-src-block "python") ;; alias all python to jupyter-python ;; (org-babel-jupyter-override-src-block "typescript") ;; alias all python to jupyter-python )
1.2.1 Usage tips
In one of the followint code blocks in org, you should be able to C-c C-c
your way to a result below
This command excecutes the block that you are currently in.
to excecute to where you are, as well as all previous code blocks, run the command M-x jupyter-org-execute-to-point
, which loads the whole org file into the jupyter kernel server
below I have set aside a few ways to test this out if you are looking at this document in org