emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nick Dokos <ndokos@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: R code block produces only partial output
Date: Tue, 05 Aug 2014 15:57:25 -0400	[thread overview]
Message-ID: <87mwbiso9m.fsf@alphaville.bos.redhat.com> (raw)
In-Reply-To: CA+M2ft8ugX-us9PdN4Ltunr60c-K5QfcD5RtnhZF52S_iMiRCQ@mail.gmail.com

John Hendy <jw.hendy@gmail.com> writes:

> On Tue, Aug 5, 2014 at 2:02 PM, Eric Schulte <schulte.eric@gmail.com> wrote:
>> Charles Berry <ccberry@ucsd.edu> writes:
>>
>>> Eric Schulte <schulte.eric <at> 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

  reply	other threads:[~2014-08-05 19:57 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-04 11:18 R code block produces only partial output Andreas Kiermeier
2014-08-04 11:53 ` Eric Schulte
2014-08-04 12:23   ` Andreas Kiermeier
2014-08-04 13:10     ` Eric Schulte
2014-08-05  0:46       ` Andreas Kiermeier
2014-08-05  4:00         ` John Hendy
2014-08-05  4:31           ` Andreas Kiermeier
2014-08-05 18:05       ` Charles Berry
2014-08-05 19:02         ` Eric Schulte
2014-08-05 19:11           ` John Hendy
2014-08-05 19:57             ` Nick Dokos [this message]
2014-08-05 20:10               ` Nick Dokos
2014-08-05 22:21             ` Charles C. Berry
2014-08-06  3:32           ` Aaron Ecay
2014-08-06 11:30             ` Eric Schulte
2014-08-07  6:00               ` Aaron Ecay
2014-08-07 17:42                 ` Charles C. Berry
2014-08-07 18:06                   ` Aaron Ecay
2014-08-07 18:42                     ` Charles C. Berry
2014-08-07 19:06                       ` Thomas S. Dye
2014-08-09  8:54                       ` Rainer M Krug
2014-08-16  5:05                     ` Aaron Ecay
2014-08-16 18:50                       ` Charles C. Berry
2014-08-16 20:58                         ` Aaron Ecay
2014-08-17  6:03                           ` Achim Gratz
2014-08-19  0:13                             ` Aaron Ecay
2014-08-19  5:36                               ` Achim Gratz
2014-08-23  8:32                                 ` Aaron Ecay
2014-08-23  9:24                                   ` Andreas Kiermeier
2014-08-23 17:10                                   ` Aaron Ecay
2014-08-23 18:35                                   ` Thomas S. Dye
2014-08-23 19:37                                     ` Ista Zahn
2014-08-24  0:10                           ` Charles C. Berry
2014-08-28  5:24                             ` Aaron Ecay
2014-09-01  5:00                               ` Aaron Ecay
2014-09-01 16:08                                 ` Charles C. Berry
2014-08-09  8:48                   ` Rainer M Krug
2014-08-06  1:11         ` Andreas Kiermeier
2014-08-06  2:21           ` Charles C. Berry
2014-08-06  3:24             ` Aaron Ecay
2014-08-06 15:59               ` Charles C. Berry

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mwbiso9m.fsf@alphaville.bos.redhat.com \
    --to=ndokos@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).