2019-06-28 16:53:26 +02:00
|
|
|
;;; lang/org/contrib/babel.el -*- lexical-binding: t; -*-
|
2019-07-09 22:44:51 +02:00
|
|
|
;;;###if (featurep! +ipython)
|
2019-06-28 16:53:26 +02:00
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! ob-ipython
|
2019-06-28 16:53:26 +02:00
|
|
|
:defer t
|
|
|
|
:init
|
|
|
|
(defvar +ob-ipython-local-runtime-dir nil)
|
|
|
|
|
|
|
|
(setq ob-ipython-resources-dir ".ob-ipython-resrc")
|
|
|
|
|
2019-07-26 22:46:05 +02:00
|
|
|
(add-hook! '+org-babel-load-functions
|
2019-07-21 02:38:42 +02:00
|
|
|
(defun +org-babel-load-ipython-h (lang)
|
|
|
|
(and (string-prefix-p "jupyter-" (symbol-name lang))
|
|
|
|
(require 'ob-ipython nil t))))
|
2019-07-10 19:00:41 +02:00
|
|
|
|
|
|
|
(after! org-src
|
|
|
|
(add-to-list 'org-src-lang-modes '("ipython" . python)))
|
2019-07-10 22:26:03 +02:00
|
|
|
(after! ox-latex
|
|
|
|
(add-to-list 'org-latex-minted-langs '(ipython "python")))
|
2019-06-28 16:53:26 +02:00
|
|
|
:config
|
|
|
|
(set-popup-rules!
|
|
|
|
'(("\\*ob-ipython.*"
|
|
|
|
:slot 2 :side right :size 100 :height 0.2
|
2019-07-10 22:26:40 +02:00
|
|
|
:select nil :quit nil :ttl nil)
|
2019-07-11 01:23:34 +02:00
|
|
|
("^ \\*Python"
|
2019-06-28 16:53:26 +02:00
|
|
|
:slot 0 :side right :size 100
|
2019-07-08 22:07:52 +02:00
|
|
|
:select nil :quit nil :ttl nil)))
|
2019-06-28 16:53:26 +02:00
|
|
|
|
|
|
|
;; advices for remote kernel and org-src-edit
|
2019-07-21 02:38:42 +02:00
|
|
|
(advice-add #'ob-ipython--create-repl :override #'+org-ob-ipython-create-repl-a)
|
|
|
|
(advice-add #'org-babel-edit-prep:ipython :override #'+org-babel-edit-prep:ipython-a)
|
|
|
|
(advice-add #'org-babel-execute:ipython :before #'+org-babel-execute:ipython-a)
|
|
|
|
(advice-add #'org-babel-ipython-initiate-session :override #'+org-ob-ipython-initiate-session-a)
|
2019-06-28 16:53:26 +02:00
|
|
|
|
|
|
|
;; retina resolution image hack
|
2019-07-08 22:07:52 +02:00
|
|
|
(when IS-MAC
|
2019-07-21 02:38:42 +02:00
|
|
|
(advice-add #'ob-ipython--write-base64-string :around #'+org-ob-ipython-write-base64-string-a))
|
2019-06-28 16:53:26 +02:00
|
|
|
|
|
|
|
;; ipython has its own async keyword, disable ipython in ob-async.
|
|
|
|
(after! ob-async
|
|
|
|
(add-to-list 'ob-async-no-async-languages-alist "ipython")))
|