1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2025-01-13 16:38:24 +00:00

ob-python: allow user choice between python.el and python-mode.el for

* lisp/ob-python.el (org-babel-python-mode): adding configuration
  option to allow users to control whether they use python.el or
  python-mode.el

  (org-babel-python-initiate-session-by-key): updated for use with new
  configuration option
This commit is contained in:
Eric Schulte 2010-07-09 10:58:12 -07:00
parent 0f5a2fb075
commit 535ea52fff

View File

@ -31,10 +31,11 @@
(require 'ob-ref)
(require 'ob-comint)
(require 'ob-eval)
(require (if (featurep 'xemacs) 'python-mode 'python))
(eval-when-compile (require 'cl))
(declare-function org-remove-indentation "org" )
(declare-function py-shell "ext:python-mode" (&optional argprompt))
(declare-function run-python "ext:python" (&optional cmd noshow new))
(add-to-list 'org-babel-tangle-lang-exts '("python" . "py"))
@ -43,6 +44,9 @@
(defvar org-babel-python-command "python"
"Name of command to use for executing python code.")
(defvar org-babel-python-mode (if (featurep 'xemacs) 'python-mode 'python)
"Preferred python mode for use in running python interactively.")
(defun org-babel-expand-body:python (body params &optional processed-params)
"Expand BODY according to PARAMS, return the expanded body."
(concat
@ -136,13 +140,16 @@ Emacs-lisp table, otherwise return the results as a string."
(defun org-babel-python-initiate-session-by-key (&optional session)
"If there is not a current inferior-process-buffer in SESSION
then create. Return the initialized session."
(require org-babel-python-mode)
(save-window-excursion
(let* ((session (if session (intern session) :default))
(python-buffer (org-babel-python-session-buffer session)))
(cond
((fboundp 'run-python) ; python.el
((and (equal 'python org-babel-python-mode)
(fboundp 'run-python)) ; python.el
(run-python))
((fboundp 'py-shell) ; python-mode.el
((and (equal 'python-mode org-babel-python-mode)
(fboundp 'py-shell)) ; python-mode.el
;; `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