Emacs IPython Notebook (EIN) provides fully featured IPython Notebook client and integrated REPL (like SLIME).
Highlighted features:
Other notebook features:
Links:
[1] | You need to setup ein:notebook-console-args properly |
[2] | Use the command ein:connect-to-notebook. |
This is a quick and clean way to try EIN separately from your Emacs setting. If you want to try EIN but think preparing all the requirements is too much, try this!:
git clone git://github.com/tkf/zeroein.git
zeroein/zeroein.py
This will launch a new Emacs instance. For more information, see:
zeroein/zeroein.py --help
Also, EIN heavily relies on standard Emacs libraries including EWOC and EIEIO. EIN is currently tested in Emacs 24.1.
Install module. Put Emacs lisp ein*.el files and Python file ein.py in your load path.
Require module:
(require 'ein)
Start IPython notebook server.
Hit M-x ein:notebooklist-open to open notebook list.
You can start notebook by M-x ein:notebooklist-open and enter the port or URL of the IPython notebook server.
Open notebook list buffer.
Ask server to create a new notebook and open it in a new buffer.
Choose notebook from all opened notebook list and open it.
Open a notebook to try random thing.
The following keybinds are available in notebook buffers.
Execute cell at point.
Toggle the visibility of the output of the cell at point. This does not alter the actual data stored in the cell.
Hide all cell output. When prefix is given, show all cell output.
Clear output from the current cell at point. Do not clear input prompt when the prefix argument is given.
Clear output from all cells. Do not clear input prompts when the prefix argument is given.
Kill (“cut”) the cell at point. Note that the kill-ring for cells is not shared with the default kill-ring of Emacs (kill-ring for texts).
Copy the cell at point. (Put the current cell into the kill-ring.)
Insert (“paste”) the latest killed cell. Prefixes are act same as the normal yank command.
Insert cell above. Insert markdown cell instead of code cell when the prefix argument is given.
Insert cell below. Insert markdown cell instead of code cell when the prefix argument is given.
Toggle the cell type of the cell at point. Use ein:notebook-change-cell-type to change the cell type directly.
Change the cell type of the current cell. Prompt will appear in the minibuffer.
Split cell at current position. Newlines at the splitting point will be removed. This can be omitted by giving a prefix argument (C-u).
Merge next cell into current cell. If prefix is given, merge current cell into previous cell.
Show the help for the object at point using tooltip. When the prefix argument C-u is given, open the help in the pager buffer. You can explicitly specify the object by selecting it.
Open traceback viewer for the traceback at point.
Send request to the server to restart kernel.
Interrupt the kernel. This is equivalent to do C-c in the console program.
Kill kernel and then kill notebook buffer. It does not kill buffer if killing kernel fails. To close notebook without killing kernel, just close the buffer as usual.
Open IPython console. To use this function, ein:notebook-console-security-dir and ein:notebook-console-args must be set properly. This function requires Fabian Gallina’s python.el for now; It should be possible to support python-mode.el. Patches are welcome!
Execute cell at point and move to the next cell, or insert if none.
Jump to the source code of the object at point. When the prefix argument C-u is given, open the source code in the other window. You can explicitly specify the object by selecting it.
Go back to the point where ein:pytools-jump-to-source-command is executed last time. When the prefix argument C-u is given, open the last point in the other window.
Evaluate a code. Prompt will appear asking the code to run. This is handy when you want to execute something quickly without making a cell. If the code outputs something, it will go to the shared output buffer. You can open the buffer by the command ein:shared-output-pop-to-buffer.
Save the notebook.
Rename current notebook and save it immediately.
NAME is any non-empty string that does not contain ‘/’ or ‘’.
Delete a cell. (WARNING: no undo!) This command has no key binding because there is no way to undo deletion. Use kill to play on the safe side.
If you really want use this command, you can do something like this (but be careful when using it!):
(define-key ein:notebook-mode-map "\C-c\C-d"
'ein:notebook-delete-cell-command)
You can connect any buffer (typically buffer opening Python file) to opened notebook and use the kernel of the notebook to execute the code, inspect objects, auto-complete code, jump to the other source, etc. Once the buffer is connected to the notebook, minor mode ein:connect-mode is enabled and the following keybinds are available.
Run buffer using the %run magic command or eval whole buffer if the prefix C-u is given. Variable ein:connect-run-command sets the command to run. You can change the command and/or set the options. See also: ein:connect-run-buffer, ein:connect-eval-buffer.
Jump to the source code of the object at point. When the prefix argument C-u is given, open the source code in the other window. You can explicitly specify the object by selecting it.
Go back to the point where ein:pytools-jump-to-source-command is executed last time. When the prefix argument C-u is given, open the last point in the other window.
Other useful commands:
Connect any buffer to notebook and its kernel.
Evaluate the whole buffer. Note that this will run the code inside the if __name__ == "__main__": block.
Run buffer using %run. Ask for command if the prefix C-u is given. Variable ein:connect-run-command sets the default command.
Traceback in notebook buffer is not easy to understand. You can open Traceback viewer by the command ein:notebook-view-traceback. In the Traceback viewer, following keybinds are available.
Keymap for ein:traceback-mode.
These commands can be used in the notebook buffer and the connected buffer.
Execute %whos magic command and popup the result.
Draw inheritance graph of the class at point. hierarchymagic extension is needed to be installed. You can explicitly specify the object by selecting it.
You can customize EIN using the Emacs customization UI by typing M-x customize-group RET ein RET. All the configurable variables are listed below.
Set to t to use preset auto-complete configuration.
Set to t to use preset a little bit hacky auto-complete configuration.
Set to t to use preset smartrep configuration.
Load development helper.
List of default url-or-port values. This will be used for completion. So put your IPython servers. You can connect to servers not in this list (but you will need to type every time).
Template of notebook name. This value is used from ein:notebooklist-new-scratch-notebook.
Configure if the output part of the cell should be saved or not.
Note that using function needs EIN lisp API, which is not defined yet. So be careful when using EIN functions. They may change.
Notebook modes to use (in order of preference).
When the notebook is opened, mode in this value is checked one by one and the first usable mode is used. By default, MuMaMo is used when it is installed. If not, a simple mode derived from python-mode is used.
Examples:
Avoid using MuMaMo even when it is installed:
(setq ein:notebook-modes (delq 'ein:notebook-mumamo-mode ein:notebook-modes))
Do not use python-mode. Use plain mode when MuMaMo is not installed:
(setq ein:notebook-modes '(ein:notebook-mumamo-mode ein:notebook-plain-mode))
Whether EIN should ask before killing unsaved notebook buffer.
Security directory setting.
Following types are valid:
IPython executable used for console.
Example: "/user/bin/ipython". Types same as ein:notebook-console-security-dir are valid.
Additional argument when using console.
Example: "--ssh HOSTNAME". Types same as ein:notebook-console-security-dir are valid.
Number of traceback stack to show. Hidden tracebacks are not discarded. You can always view them using the command ein:notebook-view-traceback.
%run magic command used for ein:connect-run-buffer. Types same as ein:notebook-console-security-dir are valid.
Whether the buffer should be saved before ein:connect-run-buffer.
Set to t to connect to the notebook after jumping to a buffer.
Major Mode for Code Cell.
Major Mode for Text Cell.
Major Mode for HTML Cell.
Major Mode for Markdown Cell.
Major Mode for Raw Cell.
Major Mode for Heading Cell.
Fallback Major Mode.