From 8217e8102e318eb97865d638400ea18176af1ed8 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Mon, 28 Jun 2010 11:15:21 -0700 Subject: [PATCH] babel: python is more selective about None->hline replacement thanks to Christopher Allan Webber for catching this * lisp/babel/langs/ob-python.el (org-babel-python-table-or-string): now more careful not to replace "None"s which are not isolated portions of lists --- lisp/babel/langs/ob-python.el | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lisp/babel/langs/ob-python.el b/lisp/babel/langs/ob-python.el index 29bb16676..cbd0837d2 100644 --- a/lisp/babel/langs/ob-python.el +++ b/lisp/babel/langs/ob-python.el @@ -101,7 +101,11 @@ specifying a var of the same value." (defun org-babel-python-table-or-string (results) "If the results look like a list or tuple, then convert them into an Emacs-lisp table, otherwise return the results as a string." - (org-babel-read + ((lambda (res) + (if (listp res) + (mapcar (lambda (el) (if (equal el 'None) 'hline el)) res) + res)) + (org-babel-read (if (or (string-match "^\\[.+\\]$" results) (string-match "^(.+)$" results)) (org-babel-read @@ -110,10 +114,8 @@ Emacs-lisp table, otherwise return the results as a string." "\\[" "(" (replace-regexp-in-string "\\]" ")" (replace-regexp-in-string ", " " " (replace-regexp-in-string - "'" "\"" - (replace-regexp-in-string - "None" "hline" results t))))))) - results))) + "'" "\"" results t)))))) + results)))) (defvar org-babel-python-buffers '(:default . nil))