0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-09-29 21:37:50 +00:00

fixed ob-python to work with newest Emacs

* lisp/ob-python.el (org-babel-python-with-earmufs): Add earmufs to a
  buffer name.
  (org-babel-python-without-earmufs): Remove earmufs from a buffer name.
  (org-babel-python-initiate-session-by-key): Set the buffer name in a
  way which is understandable by the new python.el
This commit is contained in:
Eric Schulte 2013-03-29 10:45:01 -06:00
parent 9e9edd4830
commit 993e3ee621

View file

@ -157,6 +157,20 @@ Emacs-lisp table, otherwise return the results as a string."
"Return the buffer associated with SESSION."
(cdr (assoc session org-babel-python-buffers)))
(defun org-babel-python-with-earmufs (session)
(let ((name (if (stringp session) session (format "%s" session))))
(if (and (string= "*" (substring name 0 1))
(string= "*" (substring name (- (length name) 1))))
name
(format "*%s*" name))))
(defun org-babel-python-without-earmufs (session)
(let ((name (if (stringp session) session (format "%s" session))))
(if (and (string= "*" (substring name 0 1))
(string= "*" (substring name (- (length name) 1))))
(substring name 1 (- (length name) 1))
name)))
(defvar py-default-interpreter)
(defun org-babel-python-initiate-session-by-key (&optional session)
"Initiate a python session.
@ -170,8 +184,11 @@ then create. Return the initialized session."
((and (eq 'python org-babel-python-mode)
(fboundp 'run-python)) ; python.el
(if (version< "24.1" emacs-version)
(let ((python-shell-buffer-name python-buffer))
(run-python org-babel-python-command))
(progn
(unless python-buffer (org-babel-python-with-earmufs session))
(let ((python-shell-buffer-name
(org-babel-python-without-earmufs python-buffer)))
(run-python org-babel-python-command)))
(run-python)))
((and (eq 'python-mode org-babel-python-mode)
(fboundp 'py-shell)) ; python-mode.el
@ -187,7 +204,7 @@ then create. Return the initialized session."
(concat "Python-" (symbol-name session))))
(py-which-bufname bufname))
(py-shell)
(setq python-buffer (concat "*" bufname "*"))))
(setq python-buffer (org-babel-python-earmufs bufname))))
(t
(error "No function available for running an inferior Python")))
(setq org-babel-python-buffers