From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: Extraneous output from Python code blocks using :session option Date: Sat, 14 Mar 2015 09:26:06 +0100 Message-ID: <87mw3g2dep.fsf@nicolasgoaziou.fr> References: <1931A590-8B23-4412-86C7-F3571EC466FF@haas.berkeley.edu> <87r3sv2xra.fsf@kyleam.com> <210D96E7-43E3-4438-8401-7841C6612023@haas.berkeley.edu> <87bnjxq59p.fsf@kyleam.com> <87d24dtmck.fsf@kmlap.domain.org> <87ioe5xq8a.fsf@nicolasgoaziou.fr> <877fult0yy.fsf@kmlap.domain.org> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50864) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWhNX-00089z-Cu for emacs-orgmode@gnu.org; Sat, 14 Mar 2015 04:25:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YWhNS-0007aW-EA for emacs-orgmode@gnu.org; Sat, 14 Mar 2015 04:25:03 -0400 Received: from relay6-d.mail.gandi.net ([2001:4b98:c:538::198]:42711) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWhNS-0007aB-7m for emacs-orgmode@gnu.org; Sat, 14 Mar 2015 04:24:58 -0400 In-Reply-To: <877fult0yy.fsf@kmlap.domain.org> (Kyle Meyer's message of "Fri, 13 Mar 2015 10:40:21 -0400") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Kyle Meyer Cc: Richard Stanton , emacs-orgmode@gnu.org, John Kitchin Kyle Meyer writes: > Thanks for your comments. I've attached updated patches. Thanks. > Subject: [PATCH 1/2] ob-python.el: Allow indented code in sessions > > * lisp/ob-python.el (org-babel-python-evaluate-session): Recognize > indented code in session and treat it differently to avoid syntax > errors. You also need to list new functions and variables in commit message, e.g., (org-babel-python-indented-lines-session-method): New variable. > * lisp/ob-python.el (org-babel-python-evaluate-session): Strip extra leading > "..." and ">>>" from session output. Ditto. (org-babel-python--strip-session-chars): New function. > +(defun org-babel-python--strip-session-chars (string) > + "Remove leading '>>>' and '...' from STRING. > +`org-babel-comint-with-output' splits the Python session output > +by `comint-prompt-regexp' (which includes '>>>' and '...'), but, > +in some situations, these still make it through at the start of > +the output string." Wouldn't it be better to find the situations above at the source? If may be due to some indentation problem at the beginning of the string, in which case an `org-trim' within `org-babel-comint-with-output' could solve it. WDYT? Regards,