EIN module to work with Jupyter notebooks
This commit is contained in:
parent
d7e054a8cc
commit
ea7663d4ea
5 changed files with 108 additions and 0 deletions
|
@ -41,6 +41,7 @@
|
|||
|
||||
:tools
|
||||
dired ; making dired pretty [functional]
|
||||
ein ; tame Jupyter notebooks with emacs
|
||||
electric-indent ; smarter, keyword-based electric-indent
|
||||
eshell ; a consistent, cross-platform shell (WIP)
|
||||
gist ; interacting with github gists
|
||||
|
|
39
modules/tools/ein/README.org
Normal file
39
modules/tools/ein/README.org
Normal file
|
@ -0,0 +1,39 @@
|
|||
#+TITLE: :tools ein
|
||||
|
||||
* EIN -- Emacs IPython Notebook
|
||||
|
||||
Tool to work with Jupyter notebooks within emacs.
|
||||
|
||||
* Table of Contents :TOC:
|
||||
- [[EIN -- Emacs IPython Notebook][EIN -- Emacs IPython Notebook]]
|
||||
- [[Install][Install]]
|
||||
- [[Usage][Usage]]
|
||||
- [[Configuration][Configuration]]
|
||||
|
||||
* Install
|
||||
Add =:tool ein= to your ~doom!~ call in your private ~init.el~.
|
||||
|
||||
* Usage
|
||||
Three functions are available to start EIN:
|
||||
1. ~ein:jupyter-server-start~ --- Start a jupyter server within emacs
|
||||
2. ~ein:notebooklist-login~ --- Login to an existing jupyter server
|
||||
3. ~ein:notebooklist-open~ --- Open the list of jupyter notebooks
|
||||
|
||||
These functions do not have default key bindings.
|
||||
|
||||
When ~ein:jupyter-server-start~ is called, after successfully finishing,
|
||||
~ein:notebooklist-login~ and ~ein:notebooklist-open~ will be automatically
|
||||
called.
|
||||
|
||||
When in the ~Notebook List~ buffer, the key ~o~ calls ~ace-link~ to speed up the
|
||||
process of selecting links in the buffer.
|
||||
|
||||
If ~company-mode~ is enabled as a module, ~company-ein~ will be used for
|
||||
completion purposes.
|
||||
|
||||
* Configuration
|
||||
Specify the default directory where EIN searches for notebooks using:
|
||||
|
||||
~(set! :ein-notebook-dir "~/my-notebooks")~
|
||||
|
||||
|
26
modules/tools/ein/autoload.el
Normal file
26
modules/tools/ein/autoload.el
Normal file
|
@ -0,0 +1,26 @@
|
|||
;;; tools/ein/autoload.el -*- lexical-binding: t; -*-
|
||||
|
||||
;;;###autoload
|
||||
(defun +ein/ace-link-ein ()
|
||||
"Ace jump to links in ein notebooklist."
|
||||
(interactive)
|
||||
(let ((res (avy-with +ein/ace-link-ein
|
||||
(avy--process
|
||||
(+ein--collect-ein-buffer-links)
|
||||
#'avy--overlay-pre))))
|
||||
;(avy--style-fn avy-style)))))
|
||||
(when (numberp res)
|
||||
(goto-char (1+ res))
|
||||
(widget-button-press (point)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +ein--collect-ein-buffer-links ()
|
||||
(interactive)
|
||||
(let ((end (window-end))
|
||||
points)
|
||||
(save-excursion
|
||||
(goto-char (window-start))
|
||||
(while (re-search-forward "~?/.+\\|\s\\[" end t)
|
||||
(push (+ (match-beginning 0) 1) points))
|
||||
(nreverse points))))
|
||||
|
38
modules/tools/ein/config.el
Normal file
38
modules/tools/ein/config.el
Normal file
|
@ -0,0 +1,38 @@
|
|||
;;; tools/ein/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
(defvar +ein-notebook-dir "~/"
|
||||
"Default directory from where Jupyter notebooks are to be opened.")
|
||||
|
||||
(def-setting! :ein-notebook-dir (dir)
|
||||
"Set the default directory from where to open Jupyter notebooks."
|
||||
`(setq +ein-notebook-dir ,dir))
|
||||
|
||||
|
||||
(def-package! ein
|
||||
:commands (ein:notebooklist-open ein:notebooklist-login ein:jupyter-server-start)
|
||||
:init
|
||||
(set! :popup "\\*ein:*" :ignore)
|
||||
(set! :popup "\\*ein:notebooklist *" '((side . left)) '((size . 40) (select)))
|
||||
;; Ace-link on notebook list buffers
|
||||
(add-hook! 'ein:notebooklist-mode-hook
|
||||
(map! :map ein:notebooklist-mode-map
|
||||
"o" #'+ein/ace-link-ein))
|
||||
;; Ein uses request to store http cookies. Store them in the cache dir.
|
||||
(setq request-storage-directory (concat doom-cache-dir "/request"))
|
||||
;; Auto complete with company
|
||||
(set! :company-backend '(ein:notebook-multilang-mode ein:notebook-python-mode ein:notebook-plain-mode)
|
||||
'ein:company-backend)
|
||||
:config
|
||||
;; Manually load the autoloads of EIN. This takes time...
|
||||
(load "ein-loaddefs.el" nil t t)
|
||||
(setq
|
||||
;; Slide images into rows so that we can navigate buffers with images more easily
|
||||
ein:slice-image t
|
||||
ein:jupyter-default-notebook-directory +ein-notebook-dir
|
||||
ein:jupyter-default-server-command "/usr/bin/jupyter"
|
||||
ein:jupyter-server-args '("--no-browser")
|
||||
ein:notebook-modes
|
||||
'(ein:notebook-multilang-mode ein:notebook-python-mode ein:notebook-plain-mode))
|
||||
;; Avy is required for showing links in the notebook list with ace-link.
|
||||
(require 'avy))
|
||||
|
4
modules/tools/ein/packages.el
Normal file
4
modules/tools/ein/packages.el
Normal file
|
@ -0,0 +1,4 @@
|
|||
;; -*- no-byte-compile: t; -*-
|
||||
;;; tools/ein/packages.el
|
||||
|
||||
(package! ein)
|
Loading…
Add table
Add a link
Reference in a new issue