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 16:10:34 -0400 Message-ID: <87iom6snnp.fsf@alphaville.bos.redhat.com> References: <87iom8zd24.fsf@gmail.com> <877g2oz9gv.fsf@gmail.com> <87lhr27oap.fsf@gmail.com> <87mwbiso9m.fsf@alphaville.bos.redhat.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:42763) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XEl4S-0008Ti-Tn for emacs-orgmode@gnu.org; Tue, 05 Aug 2014 16:11:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XEl4M-0004Yi-Nh for emacs-orgmode@gnu.org; Tue, 05 Aug 2014 16:10:56 -0400 Received: from plane.gmane.org ([80.91.229.3]:47855) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XEl4M-0004Yd-Ec for emacs-orgmode@gnu.org; Tue, 05 Aug 2014 16:10:50 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1XEl4J-0006Fj-S9 for emacs-orgmode@gnu.org; Tue, 05 Aug 2014 22:10:47 +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 22:10:47 +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 22:10:47 +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 Nick Dokos writes: > 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... Bah, got it wrong: backslash is not special within a character class, so [>+\\.] matches > or + or \ or . (a period - which is also not special in a character class). I'm not sure what the regexp is supposed to match, but I'm almost sure that it is wrong :-) -- Nick