gregsexton / gregsexton/ob-ipython
Removing ob-ipython-auto-configure-kernels from org mode hook
- Dominant language
- Emacs Lisp
- Stars
- 742
- Forks
- 107
- PR merge metrics
- No merged PRs in 30d
Description
I think it is a bit sneaky to modify a global variable like `org-mode-hook` when loading `ob-ipython.el` This will then get called in all org-mode buffers, even if they contain no ob-ipython src blocks, let alone execute them.
In addition, I think it is reasonable to use ob-ipython with a virtualenv and specify the virtualenv by setting a file local value for `ob-ipython-command`. This technique does not work when `ob-ipython-auto-configure-kernels` is called in the major mode hook, which is run before setting the file local variables. I suggest making the call to `ob-ipython-auto-configure-kernels` elsewhere. Here is a patch that does it in `org-babel-execute:ipython`:
``` diff
diff --git a/ob-ipython.el b/ob-ipython.el
index d043434..fe522a1 100644
--- a/ob-ipython.el
+++ b/ob-ipython.el
@@ -493,7 +493,6 @@ a new kernel will be started."
;; babel framework
(add-to-list 'org-src-lang-modes '("ipython" . python))
-(add-hook 'org-mode-hook 'ob-ipython-auto-configure-kernels)
(defvar ob-ipython-configured-kernels nil)
@@ -569,6 +568,7 @@ have previously been configured."
(defun org-babel-execute:ipython (body params)
"Execute a block of IPython code with Babel.
This function is called by `org-babel-execute-src-block'."
+ (ob-ipython-auto-configure-kernels)
(ob-ipython--clear-output-buffer)
(if (cdr (assoc :async params))
(ob-ipython--execute-async body params)
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.