Skip to content

Commit 2f14f2e

Browse files
committed
ob-jupyter.el: Generate language aliases in org-mode-hook
As opposed to generating them on the first call to `org-babel-execute-src-block` which is too late, e.g. for fontification of source blocks and editing source blocks via `org-edit-src-code`. closes #470 closes #473 closes #475
1 parent f412f08 commit 2f14f2e

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

ob-jupyter.el

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -778,16 +778,14 @@ mapped to their appropriate minted language in
778778

779779
;;; Hook into `org'
780780

781-
;; Defer generation of the aliases until the first call to
782-
;; `org-babel-execute-src-block' to avoid generating them at top-level
783-
;; when loading ob-jupyter. Some users, e.g. those who use conda
784-
;; environments, may not have a jupyter command available at load
785-
;; time.
786-
(defun org-babel-jupyter--aliases-advice (&rest _)
781+
;; Defer generation of the aliases until Org is enabled in a buffer to
782+
;; avoid generating them at top-level when loading ob-jupyter. Some
783+
;; users, e.g. those who use conda environments, may not have a
784+
;; jupyter command available at load time.
785+
(defun org-babel-jupyter-make-local-aliases ()
787786
(let ((default-directory user-emacs-directory))
788-
(org-babel-jupyter-aliases-from-kernelspecs))
789-
(advice-remove #'org-babel-execute-src-block #'org-babel-jupyter--aliases-advice))
790-
(advice-add #'org-babel-execute-src-block :before #'org-babel-jupyter--aliases-advice)
787+
(org-babel-jupyter-aliases-from-kernelspecs)))
788+
(add-hook 'org-mode-hook #'org-babel-jupyter-make-local-aliases)
791789

792790
(add-hook 'org-export-before-processing-hook #'org-babel-jupyter-setup-export)
793791
(add-hook 'org-export-before-parsing-hook #'org-babel-jupyter-strip-ansi-escapes)

0 commit comments

Comments
 (0)