From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: [BABEL] BUG Re: Omitting try/catch blocks from tangled R code? Date: Wed, 02 Apr 2014 17:09:37 -0600 Message-ID: <87bnwio5x4.fsf@gmail.com> References: <52F498AE.6090802@krugs.de> <87siruamo3.fsf@gmail.com> <52F5326C.7010505@krugs.de> <877g7syio6.fsf@gmail.com> <87txawwwh6.fsf@gmail.com> <87r45xeabf.fsf@gmail.com> <87fvm8gxok.fsf@gmail.com> <87siq7g2j5.fsf@gmail.com> <87d2h71qqc.fsf@bagel.gateway.pace.com> <87fvlzg45i.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:39795) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WViQr-00055q-88 for emacs-orgmode@gnu.org; Thu, 03 Apr 2014 10:15:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WViQm-00066P-Au for emacs-orgmode@gnu.org; Thu, 03 Apr 2014 10:15:53 -0400 Received: from mail-pd0-x230.google.com ([2607:f8b0:400e:c02::230]:42618) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WViQm-00066E-1T for emacs-orgmode@gnu.org; Thu, 03 Apr 2014 10:15:48 -0400 Received: by mail-pd0-f176.google.com with SMTP id r10so1842781pdi.21 for ; Thu, 03 Apr 2014 07:15:47 -0700 (PDT) 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: Rainer M Krug Cc: emacs-orgmode@gnu.org, Charles Berry Rainer M Krug writes: > Eric Schulte writes: > >>> >>> Apologies - I am still struggling with encryption...... >>> >>> So here is my example: >>> >>> --8<---------------cut here---------------start------------->8--- >>> #+TITLE: single_to_multi >>> #+DATE: <2013-10-15 Tue> >>> #+AUTHOR: Rainer M. Krug >>> #+EMAIL: Rainer@krugs.de >>> >>> =E2=89=88* Load R packages and data >>> #+BEGIN_SRC R >>> cat("Loading Data\n") >>> #+END_SRC >>> --8<---------------cut here---------------end--------------->8--- >>> >>> I am using only org loaded and R enabled. >>> >>> C-c C-c on the block produces the error >>> >>> emacs version:=20 >>> GNU Emacs 24.3.1 (x86_64-apple-darwin13.0.0, Carbon Version 1.6.0 >>> AppKit 1265) of 2014-02-13 on Rainers-MacBook-Pro-2.local >>> >>> org version: >>> Org-mode version 8.2.5h (release_8.2.5h-837-gb296cc @ >>> /Users/rainerkrug/.emacs.d/org-mode/lisp/) >>> >> >> Thanks, a fixed version of the patch is attached. If this works please >> let me know and I'll apply. > > Still the same error: > Your previous example works as expected for me with the latest patch. * Load R packages and data #+BEGIN_SRC R :results output cat("Loading Data\n") #+END_SRC #+RESULTS: : Loading Data Please double check that you applied the patch and reloaded Org-mode, and if the bug persists provide another minimal example. Thanks, > > ,---- > | Debugger entered--Lisp error: (wrong-type-argument sequencep 99) > | Mapconcat(identity "cat(\"YEAR\")" "\n") > | Org-babel-execute:R("cat(\"YEAR\")" ((:comments . "") (:shebang > | . "") (:cache . "no") (:padline . "") (:noweb . "no") (:tangle > | . "no") (:exports . "code") (:results . "replace output") (:session > | . "none") (:hlines . "no") (:result-type . output) (:result-params > | "output" "replace") (:rowname-names) (:colname-names))) > | org-babel-execute-src-block(nil) > | org-babel-execute-src-block-maybe() > | org-babel-execute-maybe() > | org-babel-execute-safely-maybe() > | run-hook-with-args-until-success(org-babel-execute-safely-maybe) > | org-ctrl-c-ctrl-c(nil) > | call-interactively(org-ctrl-c-ctrl-c nil nil) > `---- > > Cheers, > > Rainer > > >> >> Best, >> >> >> From d67248db79faf19e1bdcac0230c37670b6115bdd Mon Sep 17 00:00:00 2001 >> From: Eric Schulte >> Date: Sun, 23 Mar 2014 20:01:37 -0600 >> Subject: [PATCH] only wrap R code graphics-file on execution >> >> Move this out of the expand-body function so that it is *never* >> applied to tangled code. >> --- >> lisp/ob-R.el | 40 +++++++++++++++++++++------------------- >> 1 file changed, 21 insertions(+), 19 deletions(-) >> >> diff --git a/lisp/ob-R.el b/lisp/ob-R.el >> index 62aa7f2..780d99f 100644 >> --- a/lisp/ob-R.el >> +++ b/lisp/ob-R.el >> @@ -97,24 +97,15 @@ this variable.") >> "Expand BODY according to PARAMS, return the expanded body." >> (let ((graphics-file >> (or graphics-file (org-babel-R-graphical-output-file params)))) >> - (mapconcat >> - #'identity >> - (let ((inside >> - (append >> - (when (cdr (assoc :prologue params)) >> - (list (cdr (assoc :prologue params)))) >> - (org-babel-variable-assignments:R params) >> - (list body) >> - (when (cdr (assoc :epilogue params)) >> - (list (cdr (assoc :epilogue params))))))) >> - (if graphics-file >> - (append >> - (list (org-babel-R-construct-graphics-device-call >> - graphics-file params)) >> - inside >> - (list "},error=3Dfunction(e){plot(x=3D-1:1, y=3D-1:1, type= =3D'n', xlab=3D'', ylab=3D'', axes=3DFALSE); text(x=3D0, y=3D0, labels=3De$= message, col=3D'red'); paste('ERROR', e$message, sep=3D' : ')}); dev.off()"= )) >> - inside)) >> - "\n"))) >> + (mapconcat #'identity >> + (append >> + (when (cdr (assoc :prologue params)) >> + (list (cdr (assoc :prologue params)))) >> + (org-babel-variable-assignments:R params) >> + (list body) >> + (when (cdr (assoc :epilogue params)) >> + (list (cdr (assoc :epilogue params))))) >> + "\n"))) >>=20=20 >> (defun org-babel-execute:R (body params) >> "Execute a block of R code. >> @@ -127,7 +118,18 @@ This function is called by `org-babel-execute-src-b= lock'." >> (colnames-p (cdr (assoc :colnames params))) >> (rownames-p (cdr (assoc :rownames params))) >> (graphics-file (org-babel-R-graphical-output-file params)) >> - (full-body (org-babel-expand-body:R body params graphics-file)) >> + (full-body >> + (let ((inside >> + (list (org-babel-expand-body:R body params graphics-file)))) >> + (mapconcat #'identity >> + (if graphics-file >> + (append >> + (list (org-babel-R-construct-graphics-device-call >> + graphics-file params)) >> + inside >> + (list "},error=3Dfunction(e){plot(x=3D-1:1, y=3D-1:1, type=3D'= n', xlab=3D'', ylab=3D'', axes=3DFALSE); text(x=3D0, y=3D0, labels=3De$mess= age, col=3D'red'); paste('ERROR', e$message, sep=3D' : ')}); dev.off()")) >> + inside) >> + "\n"))) >> (result >> (org-babel-R-evaluate >> session full-body result-type result-params >> --=20 >> 1.9.1 --=20 Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D