2019-12-16 19:23:08 -05:00
|
|
|
;;; lang/org/contrib/jupyter.el -*- lexical-binding: t; -*-
|
2022-08-12 20:29:19 +02:00
|
|
|
;;;###if (modulep! +jupyter)
|
2019-12-16 19:23:08 -05:00
|
|
|
|
2019-12-18 10:18:58 -05:00
|
|
|
(use-package! ob-jupyter
|
2019-12-16 19:23:08 -05:00
|
|
|
:defer t
|
|
|
|
:init
|
|
|
|
(after! ob-async
|
2020-08-06 00:29:40 -04:00
|
|
|
(pushnew! ob-async-no-async-languages-alist
|
|
|
|
"jupyter-python"
|
|
|
|
"jupyter-julia"
|
|
|
|
"jupyter-R"))
|
2019-12-16 19:23:08 -05:00
|
|
|
|
2019-12-22 00:02:26 -05:00
|
|
|
(after! org-src
|
|
|
|
(dolist (lang '(python julia R))
|
|
|
|
(cl-pushnew (cons (format "jupyter-%s" lang) lang)
|
|
|
|
org-src-lang-modes :key #'car)))
|
|
|
|
|
2019-12-16 19:23:08 -05:00
|
|
|
(add-hook! '+org-babel-load-functions
|
|
|
|
(defun +org-babel-load-jupyter-h (lang)
|
2019-12-18 10:18:58 -05:00
|
|
|
(when (string-prefix-p "jupyter-" (symbol-name lang))
|
2019-12-22 00:02:26 -05:00
|
|
|
(require 'jupyter)
|
|
|
|
(let* ((lang-name (symbol-name lang))
|
|
|
|
(lang-tail (string-remove-prefix "jupyter-" lang-name)))
|
|
|
|
(and (not (assoc lang-tail org-src-lang-modes))
|
|
|
|
(require (intern (format "ob-%s" lang-tail))
|
|
|
|
nil t)
|
|
|
|
(add-to-list 'org-src-lang-modes (cons lang-name (intern lang-tail)))))
|
2019-12-18 10:18:58 -05:00
|
|
|
(with-demoted-errors "Jupyter: %s"
|
2019-12-19 15:25:29 -05:00
|
|
|
(require lang nil t)
|
2020-07-13 01:46:15 -04:00
|
|
|
(require 'ob-jupyter nil t)))))
|
|
|
|
:config
|
2020-08-06 00:29:40 -04:00
|
|
|
(defadvice! +org--ob-jupyter-initiate-session-a (&rest _)
|
|
|
|
:after #'org-babel-jupyter-initiate-session
|
|
|
|
(unless (bound-and-true-p jupyter-org-interaction-mode)
|
|
|
|
(jupyter-org-interaction-mode)))
|
|
|
|
|
2020-07-13 01:46:15 -04:00
|
|
|
(require 'tramp))
|