From 3abdec0a6df03a5a541ca3ca0cabbaeac4b593ab Mon Sep 17 00:00:00 2001 From: Isa Mert Gurbuz Date: Wed, 22 Jan 2025 21:36:01 +0100 Subject: [PATCH 1/3] Make org-client keybindings optionally enabled --- jupyter-org-client.el | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/jupyter-org-client.el b/jupyter-org-client.el index b261d2eb..d173eca3 100644 --- a/jupyter-org-client.el +++ b/jupyter-org-client.el @@ -136,6 +136,11 @@ See also the docstring of `org-image-actual-width' for more details." :group 'ob-jupyter :type 'boolean) +(defcustom jupyter-org-want-keybinding t + "Whether to enable contextual keybindings." + :group 'ob-jupyter + :type 'boolean) + (defconst jupyter-org-mime-types '(:text/org ;; Prioritize images over html :image/svg+xml :image/jpeg :image/png @@ -823,12 +828,13 @@ and they only take effect when the variable #'undefined (jupyter-org--define-key-filter key)))))))) -(jupyter-org-define-key (kbd "C-x C-e") #'jupyter-eval-line-or-region) -(jupyter-org-define-key (kbd "C-M-x") #'jupyter-eval-defun) -(jupyter-org-define-key (kbd "M-i") #'jupyter-inspect-at-point) -(jupyter-org-define-key (kbd "C-c M-:") #'jupyter-eval-string-command) -(jupyter-org-define-key (kbd "C-c C-r") #'jupyter-repl-restart-kernel) -(jupyter-org-define-key (kbd "C-c C-i") #'jupyter-repl-interrupt-kernel) +(when jupyter-org-want-keybinding + (jupyter-org-define-key (kbd "C-x C-e") #'jupyter-eval-line-or-region) + (jupyter-org-define-key (kbd "C-M-x") #'jupyter-eval-defun) + (jupyter-org-define-key (kbd "M-i") #'jupyter-inspect-at-point) + (jupyter-org-define-key (kbd "C-c M-:") #'jupyter-eval-string-command) + (jupyter-org-define-key (kbd "C-c C-r") #'jupyter-repl-restart-kernel) + (jupyter-org-define-key (kbd "C-c C-i") #'jupyter-repl-interrupt-kernel)) ;;; Handling ANSI escapes in kernel output From f9d776bfdd33eccbd9e5cce4bd71a97524958512 Mon Sep 17 00:00:00 2001 From: Isa Mert Gurbuz Date: Wed, 22 Jan 2025 21:43:47 +0100 Subject: [PATCH 2/3] Make `jupyter-org-interaction-mode` enabled optionally --- jupyter-org-client.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/jupyter-org-client.el b/jupyter-org-client.el index d173eca3..67c56379 100644 --- a/jupyter-org-client.el +++ b/jupyter-org-client.el @@ -141,6 +141,11 @@ See also the docstring of `org-image-actual-width' for more details." :group 'ob-jupyter :type 'boolean) +(defcustom jupyter-org-want-integration t + "Whether to enable `jupyter-org-interaction-mode' automatically on `org-mode' buffers." + :group 'ob-jupyter + :type 'boolean) + (defconst jupyter-org-mime-types '(:text/org ;; Prioritize images over html :image/svg+xml :image/jpeg :image/png @@ -945,7 +950,8 @@ C-x C-e `jupyter-eval-line-or-region'" (lambda (x) (eq (car x) 'jupyter-org-font-lock-ansi-escapes)) org-font-lock-keywords)))) -(add-hook 'org-mode-hook 'jupyter-org-interaction-mode) +(when jupyter-org-want-integration + (add-hook 'org-mode-hook 'jupyter-org-interaction-mode)) ;;; Constructing org syntax trees From d2b8f5f0dd5a4b2c41027c5dc9b3a676275dc87d Mon Sep 17 00:00:00 2001 From: Isa Mert Gurbuz Date: Sun, 23 Nov 2025 14:32:46 +0100 Subject: [PATCH 3/3] Move babel integration behind `jupyter-org-want-integration` --- ob-jupyter.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ob-jupyter.el b/ob-jupyter.el index 1843d7f9..1a8b8d9a 100644 --- a/ob-jupyter.el +++ b/ob-jupyter.el @@ -834,10 +834,11 @@ mapped to their appropriate minted language in (defun org-babel-jupyter-make-local-aliases () (let ((default-directory user-emacs-directory)) (org-babel-jupyter-aliases-from-kernelspecs))) -(add-hook 'org-mode-hook #'org-babel-jupyter-make-local-aliases 10) -(add-hook 'org-export-before-processing-functions #'org-babel-jupyter-setup-export) -(add-hook 'org-export-before-parsing-functions #'org-babel-jupyter-strip-ansi-escapes) +(when jupyter-org-want-integration + (add-hook 'org-mode-hook #'org-babel-jupyter-make-local-aliases 10) + (add-hook 'org-export-before-processing-functions #'org-babel-jupyter-setup-export) + (add-hook 'org-export-before-parsing-functions #'org-babel-jupyter-strip-ansi-escapes)) (provide 'ob-jupyter)