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/2] 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/2] 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