doomemacs/modules/lang/org/contrib/ipython.el
Henrik Lissner 659f7bfc71
refactor!: deprecate IS-* OS constants
BREAKING CHANGE: This deprecates the IS-(MAC|WINDOWS|LINUX|BSD) family
of global constants in favor of a native `featurep` check:

  IS-MAC      ->  (featurep :system 'macos)
  IS-WINDOWS  ->  (featurep :system 'windows)
  IS-LINUX    ->  (featurep :system 'linux)
  IS-BSD      ->  (featurep :system 'bsd)

The constants will stick around until the v3 release so folks can still
use it -- and there are still some modules that use it, but I'll phase
those uses out gradually.

Fix: #7479
2024-02-04 17:54:29 -05:00

41 lines
1.5 KiB
EmacsLisp

;;; lang/org/contrib/babel.el -*- lexical-binding: t; -*-
;;;###if (modulep! +ipython)
(use-package! ob-ipython
:defer t
:init
(defvar +ob-ipython-local-runtime-dir nil)
(setq ob-ipython-resources-dir ".ob-ipython-resrc")
(add-hook! '+org-babel-load-functions
(defun +org-babel-load-ipython-h (lang)
(and (string-prefix-p "jupyter-" (symbol-name lang))
(require 'ob-ipython nil t))))
(after! org-src
(add-to-list 'org-src-lang-modes '("ipython" . python)))
(after! ox-latex
(add-to-list 'org-latex-minted-langs '(ipython "python")))
:config
(set-popup-rules!
'(("\\*ob-ipython.*"
:slot 2 :side right :size 100 :height 0.2
:select nil :quit nil :ttl nil)
("^ \\*Python"
:slot 0 :side right :size 100
:select nil :quit nil :ttl nil)))
;; advices for remote kernel and org-src-edit
(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)
;; retina resolution image hack
(when (featurep :system 'macos)
(advice-add #'ob-ipython--write-base64-string :around #'+org-ob-ipython-write-base64-string-a))
;; ipython has its own async keyword, disable ipython in ob-async.
(after! ob-async
(add-to-list 'ob-async-no-async-languages-alist "ipython")))