diff options
author | Eric Schulte <schulte.eric@gmail.com> | 2010-07-09 10:58:12 -0700 |
---|---|---|
committer | Eric Schulte <schulte.eric@gmail.com> | 2010-07-09 10:58:12 -0700 |
commit | 535ea52fff82892645e56b6a0f9f098411d74b4f (patch) | |
tree | 6165cd90eeb0459da4b748e2ed579403786e0555 | |
parent | 0f5a2fb0754d3a0429b05060d7e22bc2313a5f2b (diff) | |
download | org-mode-535ea52fff82892645e56b6a0f9f098411d74b4f.tar.gz |
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
-rw-r--r-- | lisp/ob-python.el | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lisp/ob-python.el b/lisp/ob-python.el index b27ee05..39208fb 100644 --- a/lisp/ob-python.el +++ b/lisp/ob-python.el @@ -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 |