From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rainer M Krug Subject: Re: R code block produces only partial output Date: Sat, 09 Aug 2014 10:48:30 +0200 Message-ID: References: <87iom8zd24.fsf@gmail.com> <877g2oz9gv.fsf@gmail.com> <87lhr27oap.fsf@gmail.com> <87r40uwavs.fsf@gmail.com> <8761i5kg8f.fsf@gmail.com> <87ppgcrg8n.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34449) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XG2KV-0003gK-6d for emacs-orgmode@gnu.org; Sat, 09 Aug 2014 04:48:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XG2KP-0000fW-KS for emacs-orgmode@gnu.org; Sat, 09 Aug 2014 04:48:47 -0400 Received: from mail-we0-f171.google.com ([74.125.82.171]:49210) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XG2KP-0000fS-BQ for emacs-orgmode@gnu.org; Sat, 09 Aug 2014 04:48:41 -0400 Received: by mail-we0-f171.google.com with SMTP id p10so6633246wes.16 for ; Sat, 09 Aug 2014 01:48:40 -0700 (PDT) In-Reply-To: (Charles C. Berry's message of "Thu, 7 Aug 2014 10:42:24 -0700") 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: "Charles C. Berry" Cc: Aaron Ecay , emacs-orgmode@gnu.org, Eric Schulte --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable "Charles C. Berry" writes: > On Wed, 6 Aug 2014, Aaron Ecay wrote: > >> Hi Eric, >> >> 2014ko abuztuak 6an, Eric Schulte-ek idatzi zuen: >> >> [...] >> >>> Perhaps you could begin with a patch for the regexp issue in this >>> thread? >> >> I have pushed a patch which allows us to avoid the regex issue >> entirely by using a native R method to capture the session output to a >> file. >> >> This introduces the change that the output no longer appears in the >> session buffer, but I think that=E2=80=99s actually an improvement: we w= ere not >> previously echoing the commands to the buffer, such that the output >> would show up =E2=80=9Cout of the blue=E2=80=9D without any indication o= f how it got >> there. > > Hi Aaron, > > I like what you are trying to do, but ... > > 1) The change has at least one bug: Remote sessions are broken by this=20 > change. > > 2) The behavior of :results output is modified in ways that might not be= =20 > desired. i.e. warnings and errors will not show up in the output. > > Can you revert this change until the bugs are sorted out and consensus=20 > about the proper handling of cases like '2' is reached? > > Can I also suggest that in the future before a change is pushed, that the= =20 > patch is announced so we can try it out or at least eyeball it and discuss > issues/bugs? I think that would be a good idea, or create a separate branch for testing these features. > > Details: > > Issue 1) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > If I open a *.org file on a remote machine and C-c C-c on a src block tha= t=20 > has `:session :results output', after the usual session startup the src=20 > block fails. The session buffer shows this > > =3D=3D=3D=3D > Error in file(file, if (append) "a" else "w") : > cannot open the connection > In addition: Warning message: > In file(file, if (append) "a" else "w") : > cannot open file '/scpc:berry@:/tmp/R-1155xWV':=20 > No such file or directory >>=20 > =3D=3D=3D > > The file '/tmp/R-1155xWV' was created. > > I think if the tramp file localname is used. it might work. I do not know= =20 > tramp, but maybe something like > > (let output-file-localname > (if (tramp-tramp-file-p output-file) > (tramp-file-name-localname > (tramp-dissect-file-name output-file)) > output-file)) > > is good enough. > > > Issue 2) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > ECM: > > #+NAME: aa > #+BEGIN_SRC R :session R2 :results output > warning("this is a warning") > 1+1 > #+END_SRC > > #+RESULTS: aa > : [1] 2 > > For some purposes having the warnings in the #+RESULTS: block is helpful. > > And when revising code, having the errors in the #+RESULTS helps -=20 > especially if I have to put aside work in progress. Instead of capture.output, one could possibly use sink() as it can also capture error messages and warnings, as shown in the help: #+begin_src R=20 ## capture all the output to a file. zz <- file("all.Rout", open =3D "wt") sink(zz) sink(zz, type =3D "message") try(log("a")) ## back to the console sink(type =3D "message") sink() file.show("all.Rout") #+end_src This combined with a try() bloxk could work? Cheers, Rainer > > HTH, > > Chuck > =2D-=20 Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology,= UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Stellenbosch University South Africa Tel : +33 - (0)9 53 10 27 44 Cell: +33 - (0)6 85 62 59 98 Fax : +33 - (0)9 58 10 27 44 Fax (D): +49 - (0)3 21 21 25 22 44 email: Rainer@krugs.de Skype: RMkrug PGP: 0x0F52F982 --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.22 (Darwin) iQEcBAEBAgAGBQJT5eBjAAoJENvXNx4PUvmCtIYIAO8RkgbSzAqk3TzPMUHMp3xM 46FZMcMDpSMn/zKyGS1Qk3PzKZVHa0x+bixiUud3BP+4tvu3WH6FqDcsmlb8B6nf /DojABnqz+lv0/fVqqiqNcmivy5H15j1F7QBzlw1xSryg+7Wkhr/MsM8/W1HKiF6 PA316WfnzlrNqzSgEWUmNAOLzugJm6fJsVnaNiDoPQ/+NmW1WwK4AlD+pdNn8D7Q sRPWCHz4PitZQUkfCPcTRhEyeCGcqWaeYwkw+pnnaYvu1wmoj59oHNWW2e5oL3/f TXiD03SnbWoWUkJBVkIkgMl3mBetw64WH13i01cMSjW3oC4Uzr6ZWoJcSlsDZ88= =KQEC -----END PGP SIGNATURE----- --=-=-=--