This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
spacemacs/layers/+lang/ipython-notebook
lcos77 d7868dae22
[ipython] Fix mode name, and remove unmaintainable code
1. Previously, the code had references to ein:notebook-mode which doesn't seem
to work (anymore), so I changed these references to ein:notebook.
2. The previous code had a big convoluted function that produced the
doc-string and that was difficult to read that depended on some other
smaller functions, though not enough of them to make the code
sufficiently modular, and therefore, it wasn't very maintainable.
Besides, when I tried the previous version with the name of the mode fixed,
spacemacs hung for a long time -- it's a mystery whether spacemacs would
have continued normally if I had waited long enough. Therefore I replaced
the doc-string with a hard coded one.
3. I added some keybindings from tkamat's fork to the code for I didn't see
a good reason not to
4. I removed the cl- prefix from "second" and "mapcan", because cl is a
deprecated package. However, I'm afraid the names without the prefix might
end up being unrecognized by previous versions of emacs.
2020-03-21 21:56:38 +01:00
..
img
packages.el [ipython] Fix mode name, and remove unmaintainable code 2020-03-21 21:56:38 +01:00
README.org Add a way to start an EIN Jupyter server from Spacemacs's UI 2019-10-18 20:59:09 +02:00

IPython Notebook layer

Description

This layer adds support for the package emacs-ipython-notebook.

Do not hesitate to check the original package README here. Also the wiki has lots of informative stuff.

Features:

  • Key bindings available through transient-state or leader key
  • Lazy-loading

List of TODOS

This is a WIP, feel free to collaborate.

TODO Maybe it'd be better if there was a state for this

TODO Make more key binding to connect to a python buffer

TODO Deleting visual regions don't work, find out why

Install

Layer

To use this configuration layer, add it to your ~/.spacemacs. You will need to add ipython-notebook to the existing dotspacemacs-configuration-layers list in this file.

Dependencies

Install IPython Notebook > 3

Note that IPython Notebook has now been renamed to Jupyter Notebook.

  pip install jupyter

What needs to be run

Have an IPython notebook running

  jupyter notebook

Using the IPython notebook

Open Notebook List

This layer is lazy loaded so the transient-state will only work after you summon the command ein:notebooklist-open which is bound to SPC a y o or ein:run which is bound to SPC a y r.

Key bindings

The key bindings can be used through a transient state or the usual evil-leader.

Transient-state: ipython-notebook

Once you are in the ipython notebook you can activate the transient-state with SPC m .

The following table lists the keys. Use them as listed in the transient-state or prefix with SPC m to use with your evil-leader.

Key Function
h ein:notebook-worksheet-open-prev-or-last
j ein:worksheet-goto-next-input
k ein:worksheet-goto-prev-input
l ein:notebook-worksheet-open-next-or-first
H ein:notebook-worksheet-move-prev
J ein:worksheet-move-cell-down
K ein:worksheet-move-cell-up
L ein:notebook-worksheet-move-next
t ein:worksheet-toggle-output
d ein:worksheet-kill-cell
R ein:worksheet-rename-sheet
y ein:worksheet-copy-cell
p ein:worksheet-yank-cell
i ein:worksheet-insert-cell-below
I ein:worksheet-insert-cell-above
u ein:worksheet-change-cell-type
RET ein:worksheet-execute-cell-and-goto-next
C-l ein:worksheet-clear-output
C-S-l ein:worksheet-clear-all-output
C-o ein:console-open
C-k ein:worksheet-merge-cell
C-j spacemacs/ein:worksheet-merge-cell-next
s ein:worksheet-split-cell-at-point
C-s ein:notebook-save-notebook-command
C-r ein:notebook-rename-command
1 ein:notebook-worksheet-open-1th
2 ein:notebook-worksheet-open-2th
3 ein:notebook-worksheet-open-3th
4 ein:notebook-worksheet-open-4th
5 ein:notebook-worksheet-open-5th
6 ein:notebook-worksheet-open-6th
7 ein:notebook-worksheet-open-7th
8 ein:notebook-worksheet-open-8th
9 ein:notebook-worksheet-open-last
+ ein:notebook-worksheet-insert-next
- ein:notebook-worksheet-delete
x ein:notebook-close

Normal mode

In normal mode the following key bindings are defined:

Key Function
gj ein:worksheet-goto-next-input
gk ein:worksheet-goto-prev-input
C-RET ein:worksheet-execute-cell
S-RET ein:worksheet-execute-cell-and-goto-next

Also SPC f s saves the notebook like you would a regular buffer.

Insert mode

In normal mode the following key bindings are defined:

Key Function
C-RET ein:worksheet-execute-cell
S-RET ein:worksheet-execute-cell-and-goto-next

Traceback mode

In traceback mode the following key bindings are defined:

key Function
RET ein:tb-jump-to-source-at-point-command
n ein:tb-next-item
p ein:tb-prev-item
q bury-buffer

Screenshots

Light

/TakeV/spacemacs/media/commit/77fe8a613940c7abc41e8aa896ace32875c2fb42/layers/+lang/ipython-notebook/img/light.png

Dark

/TakeV/spacemacs/media/commit/77fe8a613940c7abc41e8aa896ace32875c2fb42/layers/+lang/ipython-notebook/img/dark.png

Bonus

If you want to have a matplotlibrc that looks good with a dark background try using this matplotlibrc. Plot background is always transparent by default so it will look okay for most dark themes out there.