From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: R code block produces only partial output Date: Tue, 05 Aug 2014 15:57:25 -0400 Message-ID: <87mwbiso9m.fsf@alphaville.bos.redhat.com> References: <87iom8zd24.fsf@gmail.com> <877g2oz9gv.fsf@gmail.com> <87lhr27oap.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:41044) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XEkrk-0006PR-5P for emacs-orgmode@gnu.org; Tue, 05 Aug 2014 15:57:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XEkrd-0000VM-W4 for emacs-orgmode@gnu.org; Tue, 05 Aug 2014 15:57:48 -0400 Received: from plane.gmane.org ([80.91.229.3]:53314) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XEkrd-0000VI-Kg for emacs-orgmode@gnu.org; Tue, 05 Aug 2014 15:57:41 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1XEkrb-000607-JV for emacs-orgmode@gnu.org; Tue, 05 Aug 2014 21:57:39 +0200 Received: from nat-pool-bos-t.redhat.com ([66.187.233.206]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 05 Aug 2014 21:57:39 +0200 Received: from ndokos by nat-pool-bos-t.redhat.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 05 Aug 2014 21:57:39 +0200 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: emacs-orgmode@gnu.org John Hendy writes: > On Tue, Aug 5, 2014 at 2:02 PM, Eric Schulte wrote: >> Charles Berry writes: >> >>> Eric Schulte gmail.com> writes: > > [snip] > >>> Eric, >>> >>> As noted by Andreas and John this is a problem for session output. >>> >>> org-babel-R-evaluate-session uses >>> >>> (string-match "^\\([ ]*[>+\\.][ ]?\\)+\\([[0-9]+\\|[ ]\\)" line) >>> >>> to find the start of R output in the session. >>> >>> This does not match the ` 0', but matches the ` .6' >>> in the output you show above, so if that had been in a session, all the >>> output up to and including the '.' before the '6' would be clipped >>> by the following >>> >>> (substring line (match-end 1)) >>> >>> >>> as Andreas output showed. >>> >>> Deleting the "\\." fixes Andreas case, but what are the circumstances >>> requiring the "\\." ? >>> >> >> I don't know. > > I'm not sure either, but was curious if someone could translate the > regex into "plain language." Maybe I could observe some typical > outputs and chime in since I use R regularly? From noob-level regex > stuff, it's looking for a new line followed by some number of spaces, > a ">" and at least one period and numbers? > It says[fn:1] ^ anchor the match at the beginning of the line \\([ ]*[>+\\.][ ]?\\)+ match any number of spaces followed by one of the three characters >, + or . (a literal period) followed by 0 or 1 space. If there is a match, remember what is matched as group 1 (that's what the escaped parentheses \\(...\\) do). Match one or more of these (that's what the + at the end does). \\([[0-9]+\\|[ ]\\) match either an emtpy space or a sequence of one or more of the characters [ or 0-9 i.e. an opening square bracket or a digit. remember what is matched as group 2. The latter will match [0[1[2[3 e.g. which does not sound right. The best way to find out what a regexp will match is to start with a buffer containing example strings that you are trying to match and example string that you are trying *not* to match, then invoke M-x regexp-builder and paste the regexp inside the empty set of quotes, then check the highligted matches to see if they agree with your expectations. Footnotes: [fn:1] Crossing fingers and toes, hoping I've got it right... -- Nick