mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-09-29 23:57:47 +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:
parent
9e9edd4830
commit
993e3ee621
|
@ -157,6 +157,20 @@ Emacs-lisp table, otherwise return the results as a string."
|
||||||
"Return the buffer associated with SESSION."
|
"Return the buffer associated with SESSION."
|
||||||
(cdr (assoc session org-babel-python-buffers)))
|
(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)
|
(defvar py-default-interpreter)
|
||||||
(defun org-babel-python-initiate-session-by-key (&optional session)
|
(defun org-babel-python-initiate-session-by-key (&optional session)
|
||||||
"Initiate a python session.
|
"Initiate a python session.
|
||||||
|
@ -170,8 +184,11 @@ then create. Return the initialized session."
|
||||||
((and (eq 'python org-babel-python-mode)
|
((and (eq 'python org-babel-python-mode)
|
||||||
(fboundp 'run-python)) ; python.el
|
(fboundp 'run-python)) ; python.el
|
||||||
(if (version< "24.1" emacs-version)
|
(if (version< "24.1" emacs-version)
|
||||||
(let ((python-shell-buffer-name python-buffer))
|
(progn
|
||||||
(run-python org-babel-python-command))
|
(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)))
|
(run-python)))
|
||||||
((and (eq 'python-mode org-babel-python-mode)
|
((and (eq 'python-mode org-babel-python-mode)
|
||||||
(fboundp 'py-shell)) ; python-mode.el
|
(fboundp 'py-shell)) ; python-mode.el
|
||||||
|
@ -187,7 +204,7 @@ then create. Return the initialized session."
|
||||||
(concat "Python-" (symbol-name session))))
|
(concat "Python-" (symbol-name session))))
|
||||||
(py-which-bufname bufname))
|
(py-which-bufname bufname))
|
||||||
(py-shell)
|
(py-shell)
|
||||||
(setq python-buffer (concat "*" bufname "*"))))
|
(setq python-buffer (org-babel-python-earmufs bufname))))
|
||||||
(t
|
(t
|
||||||
(error "No function available for running an inferior Python")))
|
(error "No function available for running an inferior Python")))
|
||||||
(setq org-babel-python-buffers
|
(setq org-babel-python-buffers
|
||||||
|
|
Loading…
Reference in a new issue