lang/org: major refactor of +ipython feature

This commit is contained in:
Henrik Lissner
2018-05-30 18:13:22 +02:00
parent 98b439e3bb
commit ebfc5648ef
4 changed files with 112 additions and 158 deletions

View File

@@ -50,3 +50,47 @@ string). Stops at the first function to return non-nil.")
for p in params
if (funcall fn (eq (car p) key))
collect p)))
;;
;; Plugins
;;
(def-package! ob-ipython
:when (featurep! +ipython)
:defer t
:init
(defvar +ob-ipython-local-runtime-dir nil
"TODO")
(setq ob-ipython-resources-dir ".ob-ipython-resrc")
(defun +org|babel-load-ipython (language)
(and (string-match-p "^jupyter-" language)
(require 'ob-ipython nil t)))
(add-hook '+org-babel-load-functions #'+org|babel-load-ipython)
:config
(set! :popups
'("^\\*Org Src"
((size . 100) (side . right) (slot . -1) (window-height . 0.6))
((quit) (select . t) (modeline)))
'("^\\*Python"
((slot . 0) (side . right) (size . 100))
((select) (quit) (transient)))
'("\\*ob-ipython.*"
((slot . 2) (side . right) (size . 100) (window-height . 0.2))
((select) (quit) (transient)))
'("\\*Python:.*"
((slot . 0) (side . right) (size . 100))
((select) (quit) (transient))))
;; TODO Add more popup styles
;; advices for remote kernel and org-src-edit
(advice-add 'org-babel-edit-prep:ipython :override #'+org*org-babel-edit-prep:ipython)
(advice-add 'org-babel-ipython-initiate-session :override #'+org*org-babel-ipython-initiate-session)
(advice-add 'ob-ipython--create-repl :override #'+org*ob-ipython--create-repl)
(advice-add 'org-babel-execute:ipython :override #'+org*org-babel-execute:ipython)
;; retina resolution image hack
(when (eq window-system 'ns)
(advice-add 'ob-ipython--write-base64-string :around #'+org*ob-ipython--write-base64-string)))