module ein: bring up to date
This commit is contained in:
parent
9f8cede4cd
commit
527c04c294
5 changed files with 6 additions and 148 deletions
|
@ -9,10 +9,6 @@
|
|||
- [[#plugins][Plugins]]
|
||||
- [[#prerequisites][Prerequisites]]
|
||||
- [[#features][Features]]
|
||||
- [[#interaction-with-a-jupyter-server][Interaction with a Jupyter server]]
|
||||
- [[#configuration][Configuration]]
|
||||
- [[#setting-the-default-location-of-your-notebooks][Setting the default location of your notebooks]]
|
||||
- [[#using-hydra][Using hydra]]
|
||||
|
||||
* Description
|
||||
Adds Jupyter notebook integration into emacs.
|
||||
|
@ -27,41 +23,4 @@ This module provides no flags.
|
|||
This module has no prereqisites.
|
||||
|
||||
* Features
|
||||
** Interaction with a Jupyter server
|
||||
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 handle completion.
|
||||
|
||||
* Configuration
|
||||
** Setting the default location of your notebooks
|
||||
Change ~+ein-notebook-dir~ to tell ein where to find your Jupityr notebooks.
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(setq +ein-notebook-dir "~/my-notebooks")
|
||||
#+END_SRC
|
||||
|
||||
** Using hydra
|
||||
This module provides a batteries-included hydra - ~+ein/hydra~ - to make using ein
|
||||
easier. Things like navigating between cells, workbook management etc, are greatly
|
||||
simplified and are easily accessible. However, by default, it's not bound to any key.
|
||||
Here's an example of how to bind it:
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(map! :map ein:notebook-mode-map
|
||||
:localleader
|
||||
"," #'+ein/hydra/body)
|
||||
#+END_SRC
|
||||
|
||||
Please refer to the README.rst at the github repository.
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
;;; tools/ein/autoload.el -*- lexical-binding: t; -*-
|
||||
|
||||
(defun +ein--collect-ein-buffer-links ()
|
||||
(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))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +ein/ace-link-ein ()
|
||||
"Ace jump to links in ein notebooklist."
|
||||
(interactive)
|
||||
(require 'avy)
|
||||
(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)))))
|
|
@ -1,47 +0,0 @@
|
|||
;;; tools/ein/autoload/hydra.el -*- lexical-binding: t; -*-
|
||||
;;;###if (featurep! :ui hydra)
|
||||
|
||||
;;;###autoload (autoload '+ein/hydra/body "tools/ein/autoload/hydra" nil t)
|
||||
(defhydra +ein/hydra (:hint nil :color red)
|
||||
"
|
||||
Operations on Cells^^^^^^ Other
|
||||
----------------------------^^^^^^ ----------------------------------^^^^
|
||||
[_k_/_j_]^^ select prev/next [_t_]^^ toggle output
|
||||
[_K_/_J_]^^ move up/down [_C-l_/_C-S-l_] clear/clear all output
|
||||
[_C-k_/_C-j_]^^ merge above/below [_C-o_]^^ open console
|
||||
[_O_/_o_]^^ insert above/below [_C-s_/_C-r_] save/rename notebook
|
||||
[_y_/_p_/_d_] copy/paste [_x_]^^ close notebook
|
||||
[_u_]^^^^ change type [_q_]^^ quit
|
||||
[_RET_]^^^^ execute
|
||||
"
|
||||
("q" nil :exit t)
|
||||
("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)
|
||||
("o" ein:worksheet-insert-cell-below)
|
||||
("O" ein:worksheet-insert-cell-above)
|
||||
("u" ein:worksheet-change-cell-type)
|
||||
("RET" ein:worksheet-execute-cell-and-goto-next)
|
||||
;; Output
|
||||
("C-l" ein:worksheet-clear-output)
|
||||
("C-S-l" ein:worksheet-clear-all-output)
|
||||
;;Console
|
||||
("C-o" ein:console-open :exit t)
|
||||
;; Merge and split cells
|
||||
("C-k" ein:worksheet-merge-cell)
|
||||
("C-j" spacemacs/ein:worksheet-merge-cell-next)
|
||||
("s" ein:worksheet-split-cell-at-point)
|
||||
;; Notebook
|
||||
("C-s" ein:notebook-save-notebook-command)
|
||||
("C-r" ein:notebook-rename-command)
|
||||
("x" ein:notebook-close :exit t))
|
|
@ -1,43 +1,14 @@
|
|||
;;; tools/ein/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
(defvar +ein-notebook-dir "~/"
|
||||
"Default directory from where Jupyter notebooks are to be opened.")
|
||||
|
||||
|
||||
;;
|
||||
;; Packages
|
||||
|
||||
(after! ein
|
||||
(setq ein:notebook-modes
|
||||
'(ein:notebook-multilang-mode
|
||||
ein:notebook-python-mode
|
||||
ein:notebook-plain-mode)
|
||||
;; Slice images into rows; easier to navigate around images
|
||||
ein:slice-image t)
|
||||
|
||||
(set-popup-rules!
|
||||
'(("\\*ein: .*" :ignore t)
|
||||
("\\*ein:tb .*" :side 'bottom :size 0.3 :quit t :ttl nil :select nil)
|
||||
("\\*ein:notebooklist *" :side 'left :size 50 :select nil)))
|
||||
|
||||
(when (featurep! :completion company)
|
||||
;; Code completion with company
|
||||
(setq ein:completion-backend 'ein:use-company-backend)
|
||||
(set-company-backend! '(ein:notebook-multilang-mode
|
||||
ein:notebook-python-mode
|
||||
ein:notebook-plain-mode)
|
||||
'ein:company-backend))
|
||||
|
||||
(after! ein-jupyter
|
||||
(setq ein:jupyter-server-args '("--no-browser"))
|
||||
(unless ein:jupyter-default-notebook-directory
|
||||
(setq ein:jupyter-default-notebook-directory "~/")))
|
||||
|
||||
(defun +ein-buffer-p (buf)
|
||||
(string-match-p "^\\*ein: .*" (buffer-name buf)))
|
||||
(or (memq (or (buffer-base-buffer buf) (current-buffer)) (ein:notebook-opened-buffers))
|
||||
(memq buf (mapcar #'ein:notebooklist-get-buffer (ein:notebooklist-keys)))))
|
||||
(add-to-list 'doom-real-buffer-functions #'+ein-buffer-p nil #'eq)
|
||||
|
||||
(map! :map ein:notebook-mode-map
|
||||
"M-s" #'ein:notebook-save-notebook-command
|
||||
"M-s" #'ein:notebook-save-notebook-command-km
|
||||
:map ein:notebooklist-mode-map
|
||||
"o" #'+ein/ace-link-ein))
|
||||
"o" #'ein:notebook-open-km))
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
;; -*- no-byte-compile: t; -*-
|
||||
;;; tools/ein/packages.el
|
||||
|
||||
(package! ein :pin "bb97c11d11")
|
||||
(package! avy :pin "cf95ba9582")
|
||||
(package! ein :pin "8a2544ab4a")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue