Browse Source

ob-python: ensure py-which-bufname is initialized

* lisp/ob-python.el (org-babel-python-initiate-session-by-key): Make
  sure that py-which-bufname is initialized, as otherwise it will be
  overwritten the first time a Python buffer is created.
Konrad Hinsen 14 years ago
parent
commit
8916e948d2
1 changed files with 6 additions and 0 deletions
  1. 6 0
      lisp/ob-python.el

+ 6 - 0
lisp/ob-python.el

@@ -35,6 +35,7 @@
 
 (declare-function org-remove-indentation "org" )
 (declare-function py-shell "ext:python-mode" (&optional argprompt))
+(declare-function py-toggle-shells "ext:python-mode" (arg))
 (declare-function run-python "ext:python" (&optional cmd noshow new))
 
 (add-to-list 'org-babel-tangle-lang-exts '("python" . "py"))
@@ -143,6 +144,11 @@ then create.  Return the initialized session."
 	(run-python))
        ((and (eq 'python-mode org-babel-python-mode)
 	     (fboundp 'py-shell)) ; python-mode.el
+	;; Make sure that py-which-bufname is initialized, as otherwise
+	;; it will be overwritten the first time a Python buffer is
+	;; created.
+	(when (fboundp 'py-shell)
+	   (py-toggle-shells py-default-interpreter))
 	;; `py-shell' creates a buffer whose name is the value of
 	;; `py-which-bufname' with '*'s at the beginning and end
 	(let* ((bufname (if python-buffer