Re: [O] [BABEL] BUG Re: Omitting try/catch blocks from tangled R code?
> > I applied the patch and it is working. > Great, I've just pushed it up. Best, -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D
Re: [O] [BABEL] BUG Re: Omitting try/catch blocks from tangled R code?
Eric Schulte writes: > 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: rai...@krugs.de ≈* 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: 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. Sorry - no idea what went wrong, but I assumed I applied the old patch. I applied the patch and it is working. Cheers, Rainer > > 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=function(e){plot(x=-1:1, y=-1:1, type='n', >>> xlab='', ylab='', axes=FALSE); text(x=0, y=0, labels=e$message, col='red'); >>> paste('ERROR', e$message, sep=' : ')}); 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"))) >>> >>> (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-block'." >>>(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 para
Re: [O] [BABEL] BUG Re: Omitting try/catch blocks from tangled R code?
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: rai...@krugs.de >>> >>> ≈* 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: >>> 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=function(e){plot(x=-1:1, y=-1:1, type='n', >> xlab='', ylab='', axes=FALSE); text(x=0, y=0, labels=e$message, col='red'); >> paste('ERROR', e$message, sep=' : ')}); 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"))) >> >> (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-block'." >> (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)) >> +
Re: [O] [BABEL] BUG Re: Omitting try/catch blocks from tangled R code?
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: rai...@krugs.de >> >> ≈* 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: >> 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: , | 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=function(e){plot(x=-1:1, y=-1:1, type='n', > xlab='', ylab='', axes=FALSE); text(x=0, y=0, labels=e$message, col='red'); > paste('ERROR', e$message, sep=' : ')}); 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"))) > > (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-block'." > (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=function(e){plot(x=-1:1, y=-1:1, > type='n', xlab='', ylab='', axes=FALSE); text(x=0, y=0, labels=e$message, > col='red'); paste('ERROR', e$message, sep=' : ')}); dev.off()")) > +inside) > + "\n"))) > (result > (org-babel-R-evaluate >session full-body result-type result-params > -- > 1.9.1 -- Rainer M. Krug email: Rainerkrugsde PGP: 0x0F52F982 pgpI5sDy3A9Y
Re: [O] [BABEL] BUG Re: Omitting try/catch blocks from tangled R code?
> > 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: rai...@krugs.de > > ≈* 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: > 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. 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=function(e){plot(x=-1:1, y=-1:1, type='n', xlab='', ylab='', axes=FALSE); text(x=0, y=0, labels=e$message, col='red'); paste('ERROR', e$message, sep=' : ')}); 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"))) (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-block'." (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=function(e){plot(x=-1:1, y=-1:1, type='n', xlab='', ylab='', axes=FALSE); text(x=0, y=0, labels=e$message, col='red'); paste('ERROR', e$message, sep=' : ')}); dev.off()")) + inside) + "\n"))) (result (org-babel-R-evaluate session full-body result-type result-params -- 1.9.1 -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D
Re: [O] [BABEL] BUG Re: Omitting try/catch blocks from tangled R code?
Eric Schulte writes: > Rainer M Krug writes: > >> Eric Schulte writes: >> >>> Rainer M Krug writes: >>> Eric Schulte writes: > Rainer M Krug writes: > >> Eric Schulte writes: >> >>> Charles Berry writes: >>> John Hendy gmail.com> writes: [deleted] > > > > I think the default behavior should be reverted, as tangling and > > exporting are two different things. When I tangle, I want to see the > > code blocks as they are in the org document (with possible > > variables and > > expansions) but not to create files where I do not put it explicitly > > into a code block. These wrappers have nothing to do with the code, > > and > > are only there for the exported engine. So I would either revert to > > the > > original behavior, or, introduce a new header argument, > > e.g. :include-wrappers, which would, if set to t, include the export > > wrappers in the tangled file. This might be useful for debugging > > exporting of code block results, but not for general tangling. > > Thanks for chiming in. This was my gut reaction to the default > behavior. I guess we're still only a sample size of 2, but > intuitively, I would think that tangling would be a separate beast in > most cases from exporting. Just to have it on the record, if I tangle, > it's usually to take the code I've used in something like a Beamer > presentation or document and combine it into a single .R file so > someone can run it without needing Org-mode. [deleted] Sorry to be late to add my $0.02... I never want the try/catch wrappers. But noweb is indispensable. I use noweb a lot to organize and collect blocks. In some cases, I export them and in others I just tangle them. I hope that the revised code will allow me to turn off try/catch wrapping and still be able to use noweb when tangling or exporting. >>> >>> In addition to noweb, there are cases where variable expansion is useful >>> in tangled code. >>> >>> The simplest option is to move things like try/catch blocks out of the >>> code block expansion function, and into the execution function. Then if >>> other language present similar constructs (which we want to add to >>> execution by default but never want to tangle), we can think about >>> abstracting this out into some new level of code block expansion. >>> >>> Thoughts? >> >> Makes perfect sense to me, and would definitely be the better place to >> add them. >> >> If one wants enclosing code in the tangling, there is always >> the :epilogue and :prologue header arguments, and the try/catch should >> be considered as internal to the execution. >> > > Great, how's this patch work? If it looks good I'll apply it. Git still puzzles me a lot... If you tell me how I can apply this patch (from emacs?) I will try it out. >>> >>> Here are some instructions from the command line. >>> >>> 1. write the patch out to a file on disk, say /tmp/0001-etc...patch >>> >>> 2. cd into the org-mode directory >>> >>> 3. make sure you're up to date with the latest >>> >>> git pull >>> >>> 4. apply the patch >>> >>> git am /tmp/0001-etc...patch >>> >>> and that should do it. >> >> OK - managed to apply the patch. >> >> Using >> >> Org-mode version 8.2.5h (release_8.2.5h-846-geb806d @ >> /Users/rainerkrug/.emacs.d/org-mode/lisp/) >> >> updated this morning, I get the following error: >> > > Could you provide a minimal example file generating this error? 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: rai...@krugs.de ≈* 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: 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/) Cheers, Rainer > > Thanks, > >> >> , >> | Debugger entered--Lisp error: (wrong-type-argument sequencep 67) >> | mapconcat(identity "COLUMNS <- >> | >> read.table(\"/var/folders/50/wcr5bjwn75q595n6x82gxj28gn/T/babel-21363l1U/R-import-21363S9b\",\n >> | header=TRUE,\n row.names=1,\n sep=\"\\t\",\n >> | as.is=TRUE)\nCOLS_TO_EVAL <- >> | >> read.table(\"/var/folders/50/wcr5bjwn75q5
Re: [O] [BABEL] BUG Re: Omitting try/catch blocks from tangled R code?
bini55Rmu2tZs.bin Description: application/pgp-encrypted binZzbsrmcnDw.bin Description: Binary data
Re: [O] [BABEL] BUG Re: Omitting try/catch blocks from tangled R code?
Rainer M Krug writes: > Eric Schulte writes: > >> Rainer M Krug writes: >> >>> Eric Schulte writes: >>> Rainer M Krug writes: > Eric Schulte writes: > >> Charles Berry writes: >> >>> John Hendy gmail.com> writes: >>> >>> [deleted] > > I think the default behavior should be reverted, as tangling and > exporting are two different things. When I tangle, I want to see the > code blocks as they are in the org document (with possible variables > and > expansions) but not to create files where I do not put it explicitly > into a code block. These wrappers have nothing to do with the code, > and > are only there for the exported engine. So I would either revert to > the > original behavior, or, introduce a new header argument, > e.g. :include-wrappers, which would, if set to t, include the export > wrappers in the tangled file. This might be useful for debugging > exporting of code block results, but not for general tangling. Thanks for chiming in. This was my gut reaction to the default behavior. I guess we're still only a sample size of 2, but intuitively, I would think that tangling would be a separate beast in most cases from exporting. Just to have it on the record, if I tangle, it's usually to take the code I've used in something like a Beamer presentation or document and combine it into a single .R file so someone can run it without needing Org-mode. >>> >>> [deleted] >>> >>> Sorry to be late to add my $0.02... >>> >>> I never want the try/catch wrappers. >>> >>> But noweb is indispensable. >>> >>> I use noweb a lot to organize and collect blocks. In some cases, I >>> export >>> them and in others I just tangle them. >>> >>> I hope that the revised code will allow me to turn off try/catch >>> wrapping >>> and still be able to use noweb when tangling or exporting. >>> >> >> In addition to noweb, there are cases where variable expansion is useful >> in tangled code. >> >> The simplest option is to move things like try/catch blocks out of the >> code block expansion function, and into the execution function. Then if >> other language present similar constructs (which we want to add to >> execution by default but never want to tangle), we can think about >> abstracting this out into some new level of code block expansion. >> >> Thoughts? > > Makes perfect sense to me, and would definitely be the better place to > add them. > > If one wants enclosing code in the tangling, there is always > the :epilogue and :prologue header arguments, and the try/catch should > be considered as internal to the execution. > Great, how's this patch work? If it looks good I'll apply it. >>> >>> Git still puzzles me a lot... If you tell me how I can apply this patch >>> (from emacs?) I will try it out. >>> >> >> Here are some instructions from the command line. >> >> 1. write the patch out to a file on disk, say /tmp/0001-etc...patch >> >> 2. cd into the org-mode directory >> >> 3. make sure you're up to date with the latest >> >> git pull >> >> 4. apply the patch >> >> git am /tmp/0001-etc...patch >> >> and that should do it. > > OK - managed to apply the patch. > > Using > > Org-mode version 8.2.5h (release_8.2.5h-846-geb806d @ > /Users/rainerkrug/.emacs.d/org-mode/lisp/) > > updated this morning, I get the following error: > Could you provide a minimal example file generating this error? Thanks, > > , > | Debugger entered--Lisp error: (wrong-type-argument sequencep 67) > | mapconcat(identity "COLUMNS <- > | > read.table(\"/var/folders/50/wcr5bjwn75q595n6x82gxj28gn/T/babel-21363l1U/R-import-21363S9b\",\n > | header=TRUE,\n row.names=1,\n sep=\"\\t\",\n > | as.is=TRUE)\nCOLS_TO_EVAL <- > | > read.table(\"/var/folders/50/wcr5bjwn75q595n6x82gxj28gn/T/babel-21363l1U/R-import-21363fHi\",\n > | header=TRUE,\n row.names=1,\n sep=\"\\t\",\n as.is=TRUE)\nALLSPECIES > | <- > | > read.table(\"/var/folders/50/wcr5bjwn75q595n6x82gxj28gn/T/babel-21363l1U/R-import-21363sRo\",\n > | header=TRUE,\n row.names=1,\n sep=\"\\t\",\n as.is=TRUE)\nSPECIES <- > | > read.table(\"/var/folders/50/wcr5bjwn75q595n6x82gxj28gn/T/babel-21363l1U/R-import-213635bu\",\n > | header=TRUE,\n row.names=1,\n sep=\"\\t\",\n as.is=TRUE)\nYEARS <- > | > read.table(\"/var/folders/50/wcr5bjwn75q595n6x82gxj28gn/T/babel-21363l1U/R-import-21363Gm0\",\n > | header=TRUE,\n row.names=1,\n sep=\"\\t\",\n as.is=TRUE)\nPRESENT <- > | 2008\nMINEFFORT <- 3\nPROPTRAIN <- 0.6\nRNGSEED <- 13\nRNGKIND <- > | \"Mersenne-Twister\"\nRNGNORMALKIND <- \"Inversion\"\nREFGRID <- > | \"./refGrid_8km.rds\"\nIFN <- > | \"./__BOX__/IFN/DB_IFN/rds/tabplot.rd
Re: [O] [BABEL] BUG Re: Omitting try/catch blocks from tangled R code?
Eric Schulte writes: > Rainer M Krug writes: > >> Eric Schulte writes: >> >>> Rainer M Krug writes: >>> Eric Schulte writes: > Charles Berry writes: > >> John Hendy gmail.com> writes: >> >> [deleted] >>> > >>> > I think the default behavior should be reverted, as tangling and >>> > exporting are two different things. When I tangle, I want to see the >>> > code blocks as they are in the org document (with possible variables >>> > and >>> > expansions) but not to create files where I do not put it explicitly >>> > into a code block. These wrappers have nothing to do with the code, >>> > and >>> > are only there for the exported engine. So I would either revert to >>> > the >>> > original behavior, or, introduce a new header argument, >>> > e.g. :include-wrappers, which would, if set to t, include the export >>> > wrappers in the tangled file. This might be useful for debugging >>> > exporting of code block results, but not for general tangling. >>> >>> Thanks for chiming in. This was my gut reaction to the default >>> behavior. I guess we're still only a sample size of 2, but >>> intuitively, I would think that tangling would be a separate beast in >>> most cases from exporting. Just to have it on the record, if I tangle, >>> it's usually to take the code I've used in something like a Beamer >>> presentation or document and combine it into a single .R file so >>> someone can run it without needing Org-mode. >> >> [deleted] >> >> Sorry to be late to add my $0.02... >> >> I never want the try/catch wrappers. >> >> But noweb is indispensable. >> >> I use noweb a lot to organize and collect blocks. In some cases, I export >> them and in others I just tangle them. >> >> I hope that the revised code will allow me to turn off try/catch wrapping >> and still be able to use noweb when tangling or exporting. >> > > In addition to noweb, there are cases where variable expansion is useful > in tangled code. > > The simplest option is to move things like try/catch blocks out of the > code block expansion function, and into the execution function. Then if > other language present similar constructs (which we want to add to > execution by default but never want to tangle), we can think about > abstracting this out into some new level of code block expansion. > > Thoughts? Makes perfect sense to me, and would definitely be the better place to add them. If one wants enclosing code in the tangling, there is always the :epilogue and :prologue header arguments, and the try/catch should be considered as internal to the execution. >>> >>> Great, how's this patch work? If it looks good I'll apply it. >> >> Git still puzzles me a lot... If you tell me how I can apply this patch >> (from emacs?) I will try it out. >> > > Here are some instructions from the command line. > > 1. write the patch out to a file on disk, say /tmp/0001-etc...patch > > 2. cd into the org-mode directory > > 3. make sure you're up to date with the latest > > git pull > > 4. apply the patch > > git am /tmp/0001-etc...patch > > and that should do it. OK - managed to apply the patch. Using Org-mode version 8.2.5h (release_8.2.5h-846-geb806d @ /Users/rainerkrug/.emacs.d/org-mode/lisp/) updated this morning, I get the following error: , | Debugger entered--Lisp error: (wrong-type-argument sequencep 67) | mapconcat(identity "COLUMNS <- read.table(\"/var/folders/50/wcr5bjwn75q595n6x82gxj28gn/T/babel-21363l1U/R-import-21363S9b\",\n header=TRUE,\n row.names=1,\n sep=\"\\t\",\n as.is=TRUE)\nCOLS_TO_EVAL <- read.table(\"/var/folders/50/wcr5bjwn75q595n6x82gxj28gn/T/babel-21363l1U/R-import-21363fHi\",\n header=TRUE,\n row.names=1,\n sep=\"\\t\",\n as.is=TRUE)\nALLSPECIES <- read.table(\"/var/folders/50/wcr5bjwn75q595n6x82gxj28gn/T/babel-21363l1U/R-import-21363sRo\",\n header=TRUE,\n row.names=1,\n sep=\"\\t\",\n as.is=TRUE)\nSPECIES <- read.table(\"/var/folders/50/wcr5bjwn75q595n6x82gxj28gn/T/babel-21363l1U/R-import-213635bu\",\n header=TRUE,\n row.names=1,\n sep=\"\\t\",\n as.is=TRUE)\nYEARS <- read.table(\"/var/folders/50/wcr5bjwn75q595n6x82gxj28gn/T/babel-21363l1U/R-import-21363Gm0\",\n header=TRUE,\n row.names=1,\n sep=\"\\t\",\n as.is=TRUE)\nPRESENT <- 2008\nMINEFFORT <- 3\nPROPTRAIN <- 0.6\nRNGSEED <- 13\nRNGKIND <- \"Mersen
Re: [O] [BABEL] BUG Re: Omitting try/catch blocks from tangled R code?
Rainer M Krug writes: > Eric Schulte writes: > >> Rainer M Krug writes: >> >>> Eric Schulte writes: >>> Charles Berry writes: > John Hendy gmail.com> writes: > > [deleted] >> > >> > I think the default behavior should be reverted, as tangling and >> > exporting are two different things. When I tangle, I want to see the >> > code blocks as they are in the org document (with possible variables >> > and >> > expansions) but not to create files where I do not put it explicitly >> > into a code block. These wrappers have nothing to do with the code, and >> > are only there for the exported engine. So I would either revert to the >> > original behavior, or, introduce a new header argument, >> > e.g. :include-wrappers, which would, if set to t, include the export >> > wrappers in the tangled file. This might be useful for debugging >> > exporting of code block results, but not for general tangling. >> >> Thanks for chiming in. This was my gut reaction to the default >> behavior. I guess we're still only a sample size of 2, but >> intuitively, I would think that tangling would be a separate beast in >> most cases from exporting. Just to have it on the record, if I tangle, >> it's usually to take the code I've used in something like a Beamer >> presentation or document and combine it into a single .R file so >> someone can run it without needing Org-mode. > > [deleted] > > Sorry to be late to add my $0.02... > > I never want the try/catch wrappers. > > But noweb is indispensable. > > I use noweb a lot to organize and collect blocks. In some cases, I export > them and in others I just tangle them. > > I hope that the revised code will allow me to turn off try/catch wrapping > and still be able to use noweb when tangling or exporting. > In addition to noweb, there are cases where variable expansion is useful in tangled code. The simplest option is to move things like try/catch blocks out of the code block expansion function, and into the execution function. Then if other language present similar constructs (which we want to add to execution by default but never want to tangle), we can think about abstracting this out into some new level of code block expansion. Thoughts? >>> >>> Makes perfect sense to me, and would definitely be the better place to >>> add them. >>> >>> If one wants enclosing code in the tangling, there is always >>> the :epilogue and :prologue header arguments, and the try/catch should >>> be considered as internal to the execution. >>> >> >> Great, how's this patch work? If it looks good I'll apply it. > > Git still puzzles me a lot... If you tell me how I can apply this patch > (from emacs?) I will try it out. > Here are some instructions from the command line. 1. write the patch out to a file on disk, say /tmp/0001-etc...patch 2. cd into the org-mode directory 3. make sure you're up to date with the latest git pull 4. apply the patch git am /tmp/0001-etc...patch and that should do it. Best, > > Thanks, > > Rainer > >> >> Thanks, -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D
Re: [O] [BABEL] BUG Re: Omitting try/catch blocks from tangled R code?
Eric Schulte writes: > Rainer M Krug writes: > >> Eric Schulte writes: >> >>> Charles Berry writes: >>> John Hendy gmail.com> writes: [deleted] > > > > I think the default behavior should be reverted, as tangling and > > exporting are two different things. When I tangle, I want to see the > > code blocks as they are in the org document (with possible variables and > > expansions) but not to create files where I do not put it explicitly > > into a code block. These wrappers have nothing to do with the code, and > > are only there for the exported engine. So I would either revert to the > > original behavior, or, introduce a new header argument, > > e.g. :include-wrappers, which would, if set to t, include the export > > wrappers in the tangled file. This might be useful for debugging > > exporting of code block results, but not for general tangling. > > Thanks for chiming in. This was my gut reaction to the default > behavior. I guess we're still only a sample size of 2, but > intuitively, I would think that tangling would be a separate beast in > most cases from exporting. Just to have it on the record, if I tangle, > it's usually to take the code I've used in something like a Beamer > presentation or document and combine it into a single .R file so > someone can run it without needing Org-mode. [deleted] Sorry to be late to add my $0.02... I never want the try/catch wrappers. But noweb is indispensable. I use noweb a lot to organize and collect blocks. In some cases, I export them and in others I just tangle them. I hope that the revised code will allow me to turn off try/catch wrapping and still be able to use noweb when tangling or exporting. >>> >>> In addition to noweb, there are cases where variable expansion is useful >>> in tangled code. >>> >>> The simplest option is to move things like try/catch blocks out of the >>> code block expansion function, and into the execution function. Then if >>> other language present similar constructs (which we want to add to >>> execution by default but never want to tangle), we can think about >>> abstracting this out into some new level of code block expansion. >>> >>> Thoughts? >> >> Makes perfect sense to me, and would definitely be the better place to >> add them. >> >> If one wants enclosing code in the tangling, there is always >> the :epilogue and :prologue header arguments, and the try/catch should >> be considered as internal to the execution. >> > > Great, how's this patch work? If it looks good I'll apply it. Git still puzzles me a lot... If you tell me how I can apply this patch (from emacs?) I will try it out. Thanks, Rainer > > Thanks, -- Rainer M. Krug email: Rainerkrugsde PGP: 0x0F52F982 pgp2vOWpX0Aa5.pgp Description: PGP signature
Re: [O] [BABEL] BUG Re: Omitting try/catch blocks from tangled R code?
Rainer M Krug writes: > Eric Schulte writes: > >> Charles Berry writes: >> >>> John Hendy gmail.com> writes: >>> >>> [deleted] > > I think the default behavior should be reverted, as tangling and > exporting are two different things. When I tangle, I want to see the > code blocks as they are in the org document (with possible variables and > expansions) but not to create files where I do not put it explicitly > into a code block. These wrappers have nothing to do with the code, and > are only there for the exported engine. So I would either revert to the > original behavior, or, introduce a new header argument, > e.g. :include-wrappers, which would, if set to t, include the export > wrappers in the tangled file. This might be useful for debugging > exporting of code block results, but not for general tangling. Thanks for chiming in. This was my gut reaction to the default behavior. I guess we're still only a sample size of 2, but intuitively, I would think that tangling would be a separate beast in most cases from exporting. Just to have it on the record, if I tangle, it's usually to take the code I've used in something like a Beamer presentation or document and combine it into a single .R file so someone can run it without needing Org-mode. >>> >>> [deleted] >>> >>> Sorry to be late to add my $0.02... >>> >>> I never want the try/catch wrappers. >>> >>> But noweb is indispensable. >>> >>> I use noweb a lot to organize and collect blocks. In some cases, I export >>> them and in others I just tangle them. >>> >>> I hope that the revised code will allow me to turn off try/catch wrapping >>> and still be able to use noweb when tangling or exporting. >>> >> >> In addition to noweb, there are cases where variable expansion is useful >> in tangled code. >> >> The simplest option is to move things like try/catch blocks out of the >> code block expansion function, and into the execution function. Then if >> other language present similar constructs (which we want to add to >> execution by default but never want to tangle), we can think about >> abstracting this out into some new level of code block expansion. >> >> Thoughts? > > Makes perfect sense to me, and would definitely be the better place to > add them. > > If one wants enclosing code in the tangling, there is always > the :epilogue and :prologue header arguments, and the try/catch should > be considered as internal to the execution. > Great, how's this patch work? If it looks good I'll apply it. Thanks, >From 838f26c35867e7af0dc46698db41d4df13dfb890 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 | 39 --- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/lisp/ob-R.el b/lisp/ob-R.el index 62aa7f2..bf7029c 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=function(e){plot(x=-1:1, y=-1:1, type='n', xlab='', ylab='', axes=FALSE); text(x=0, y=0, labels=e$message, col='red'); paste('ERROR', e$message, sep=' : ')}); 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"))) (defun org-babel-execute:R (body params) "Execute a block of R code. @@ -127,7 +118,17 @@ This function is called by `org-babel-execute-src-block'." (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 (org-babel-expand-body:R body params graphics-file))) + (mapconcat #'identity + (if graphics-file + (append + (list (org-babel-R-construct-graphics-device-call + graphics-fil
Re: [O] [BABEL] BUG Re: Omitting try/catch blocks from tangled R code?
Eric Schulte writes: > Charles Berry writes: > >> John Hendy gmail.com> writes: >> >> [deleted] >>> > >>> > I think the default behavior should be reverted, as tangling and >>> > exporting are two different things. When I tangle, I want to see the >>> > code blocks as they are in the org document (with possible variables and >>> > expansions) but not to create files where I do not put it explicitly >>> > into a code block. These wrappers have nothing to do with the code, and >>> > are only there for the exported engine. So I would either revert to the >>> > original behavior, or, introduce a new header argument, >>> > e.g. :include-wrappers, which would, if set to t, include the export >>> > wrappers in the tangled file. This might be useful for debugging >>> > exporting of code block results, but not for general tangling. >>> >>> Thanks for chiming in. This was my gut reaction to the default >>> behavior. I guess we're still only a sample size of 2, but >>> intuitively, I would think that tangling would be a separate beast in >>> most cases from exporting. Just to have it on the record, if I tangle, >>> it's usually to take the code I've used in something like a Beamer >>> presentation or document and combine it into a single .R file so >>> someone can run it without needing Org-mode. >> >> [deleted] >> >> Sorry to be late to add my $0.02... >> >> I never want the try/catch wrappers. >> >> But noweb is indispensable. >> >> I use noweb a lot to organize and collect blocks. In some cases, I export >> them and in others I just tangle them. >> >> I hope that the revised code will allow me to turn off try/catch wrapping >> and still be able to use noweb when tangling or exporting. >> > > In addition to noweb, there are cases where variable expansion is useful > in tangled code. > > The simplest option is to move things like try/catch blocks out of the > code block expansion function, and into the execution function. Then if > other language present similar constructs (which we want to add to > execution by default but never want to tangle), we can think about > abstracting this out into some new level of code block expansion. > > Thoughts? Makes perfect sense to me, and would definitely be the better place to add them. If one wants enclosing code in the tangling, there is always the :epilogue and :prologue header arguments, and the try/catch should be considered as internal to the execution. Rainer > >> >> Best, >> >> Chuck >> >> -- Rainer M. Krug email: Rainerkrugsde PGP: 0x0F52F982 pgpAsJeYJDIhw.pgp Description: PGP signature
Re: [O] [BABEL] BUG Re: Omitting try/catch blocks from tangled R code?
Charles Berry writes: > John Hendy gmail.com> writes: > > [deleted] >> > >> > I think the default behavior should be reverted, as tangling and >> > exporting are two different things. When I tangle, I want to see the >> > code blocks as they are in the org document (with possible variables and >> > expansions) but not to create files where I do not put it explicitly >> > into a code block. These wrappers have nothing to do with the code, and >> > are only there for the exported engine. So I would either revert to the >> > original behavior, or, introduce a new header argument, >> > e.g. :include-wrappers, which would, if set to t, include the export >> > wrappers in the tangled file. This might be useful for debugging >> > exporting of code block results, but not for general tangling. >> >> Thanks for chiming in. This was my gut reaction to the default >> behavior. I guess we're still only a sample size of 2, but >> intuitively, I would think that tangling would be a separate beast in >> most cases from exporting. Just to have it on the record, if I tangle, >> it's usually to take the code I've used in something like a Beamer >> presentation or document and combine it into a single .R file so >> someone can run it without needing Org-mode. > > [deleted] > > Sorry to be late to add my $0.02... > > I never want the try/catch wrappers. > > But noweb is indispensable. > > I use noweb a lot to organize and collect blocks. In some cases, I export > them and in others I just tangle them. > > I hope that the revised code will allow me to turn off try/catch wrapping > and still be able to use noweb when tangling or exporting. > In addition to noweb, there are cases where variable expansion is useful in tangled code. The simplest option is to move things like try/catch blocks out of the code block expansion function, and into the execution function. Then if other language present similar constructs (which we want to add to execution by default but never want to tangle), we can think about abstracting this out into some new level of code block expansion. Thoughts? > > Best, > > Chuck > > -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D
Re: [O] [BABEL] BUG Re: Omitting try/catch blocks from tangled R code?
John Hendy gmail.com> writes: [deleted] > > > > I think the default behavior should be reverted, as tangling and > > exporting are two different things. When I tangle, I want to see the > > code blocks as they are in the org document (with possible variables and > > expansions) but not to create files where I do not put it explicitly > > into a code block. These wrappers have nothing to do with the code, and > > are only there for the exported engine. So I would either revert to the > > original behavior, or, introduce a new header argument, > > e.g. :include-wrappers, which would, if set to t, include the export > > wrappers in the tangled file. This might be useful for debugging > > exporting of code block results, but not for general tangling. > > Thanks for chiming in. This was my gut reaction to the default > behavior. I guess we're still only a sample size of 2, but > intuitively, I would think that tangling would be a separate beast in > most cases from exporting. Just to have it on the record, if I tangle, > it's usually to take the code I've used in something like a Beamer > presentation or document and combine it into a single .R file so > someone can run it without needing Org-mode. ]deleted] Sorry to be late to add my $0.02... I never want the try/catch wrappers. But noweb is indispensable. I use noweb a lot to organize and collect blocks. In some cases, I export them and in others I just tangle them. I hope that the revised code will allow me to turn off try/catch wrapping and still be able to use noweb when tangling or exporting. Best, Chuck
Re: [O] [BABEL] BUG Re: Omitting try/catch blocks from tangled R code?
On Tue, Mar 18, 2014 at 3:44 AM, Rainer M Krug wrote: > Eric Schulte writes: > >> John Hendy writes: >> >>> On Mon, Mar 17, 2014 at 10:00 AM, Eric Schulte >>> wrote: John Hendy writes: >>> Out of curiosity, is there a consensus that this is the preferred >>> behavior for tangling by default? >> >> There may have been a consensus in a single thread motivated by a single >> use case, which should not necessarily be a global consensus. >> >>> I'm guessing at some point it was decided that the need was preferred >>> to have these bits inserted before/after code blocks, but just trying >>> to confirm this. It seems odd to me, at least given R's behavior, that >>> someone would prefer these bits to show up in the tangled file since >>> they appeared to serve the purpose of having Org not fail during >>> export vs. benefitting the code in any way (if I wasn't running code >>> through R, I'd just get the errors directly). >>> >> >> I'd be happy to add :no-expand to the default R header arguments. Or >> even to change this behavior globally, if the current behavior is >> universally surprising. > > I think the default behavior should be reverted, as tangling and > exporting are two different things. When I tangle, I want to see the > code blocks as they are in the org document (with possible variables and > expansions) but not to create files where I do not put it explicitly > into a code block. These wrappers have nothing to do with the code, and > are only there for the exported engine. So I would either revert to the > original behavior, or, introduce a new header argument, > e.g. :include-wrappers, which would, if set to t, include the export > wrappers in the tangled file. This might be useful for debugging > exporting of code block results, but not for general tangling. Thanks for chiming in. This was my gut reaction to the default behavior. I guess we're still only a sample size of 2, but intuitively, I would think that tangling would be a separate beast in most cases from exporting. Just to have it on the record, if I tangle, it's usually to take the code I've used in something like a Beamer presentation or document and combine it into a single .R file so someone can run it without needing Org-mode. Re. the :include-wrappers argument, it sounds like :no-expand already exists for this purpose... I'd just suggest (especially with your second opinion) that it be the default value vs. having to manually set it. Best regards, John > > Cheers, > > Rainer > >> >> Best, >> >>> >>> >>> John >>> Best, -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D > > -- > Rainer M. Krug > > email: RMKruggmailcom
Re: [O] [BABEL] BUG Re: Omitting try/catch blocks from tangled R code?
Eric Schulte writes: > John Hendy writes: > >> On Mon, Mar 17, 2014 at 10:00 AM, Eric Schulte >> wrote: >>> John Hendy writes: >>> On Fri, Feb 7, 2014 at 1:22 PM, Rainer M Krug wrote: > > > > On 02/07/14, 17:47 , Eric Schulte wrote: > > Rainer M Krug writes: > > > >> On 02/07/14, 07:18 , John Hendy wrote: > >>> Greetings, > >>> > >>> > >>> I don't usually tangle, but am creating a code file to go along with a > >>> presentation I'm giving this weekend so that attendees can try things > >>> out afterward by cloning my github repo where all the data and > >>> necessary files are stored. > >>> > >>> In my presentation (Beamer), I create plots via the R pdf() device, > >>> and noticed that all of the tangled code where plots are generated > >>> contains the following: > >>> > >>> pdf(file="file.pdf"); tryCatch({ > >>> > >>> code block contents here > >>> > >>> },error=function(e){plot(x=-1:1, y=-1:1, type='n', xlab='', ylab='', > >>> axes=FALSE); text(x=0, y=0, labels=e$message, col='red'); > >>> paste('ERROR', e$message, sep=' : ')}); dev.off() > >>> > >>> Is there a way to omit this? > >> > >> This is a bug which must have been introduced some time ago - in the > >> stock version of emacs (Org-mode version 7.9.3f > >> (release_7.9.3f-17-g7524ef @ > >> /usr/local/Cellar/emacs/24.3/share/emacs/24.3/lisp/org/)) it does not > >> tangle the enclosing commands to create graphics, but in 8.2 it does (I > >> don't have an older version at hand to go further back). > >> > > > > I believe this was introduced by your commit eaa3a761d. Reversion of > > which with the following should provide a temporary workaround. > >>> >>> I take this back, the behavior is unrelated to Rainer's commit adding >>> try/catch blocks to R graphics creation logic. >>> >>> In fact I don't believe this is a bug, rather the default behavior is to >>> expand code block bodies on tangling. This behavior may be changed by >>> using the :no-expand header argument which will inhibit code block body >>> expansion during tangling. >>> >> >> Got it, and thanks for the new variable tip! >> >> Out of curiosity, is there a consensus that this is the preferred >> behavior for tangling by default? > > There may have been a consensus in a single thread motivated by a single > use case, which should not necessarily be a global consensus. > >> I'm guessing at some point it was decided that the need was preferred >> to have these bits inserted before/after code blocks, but just trying >> to confirm this. It seems odd to me, at least given R's behavior, that >> someone would prefer these bits to show up in the tangled file since >> they appeared to serve the purpose of having Org not fail during >> export vs. benefitting the code in any way (if I wasn't running code >> through R, I'd just get the errors directly). >> > > I'd be happy to add :no-expand to the default R header arguments. Or > even to change this behavior globally, if the current behavior is > universally surprising. I think the default behavior should be reverted, as tangling and exporting are two different things. When I tangle, I want to see the code blocks as they are in the org document (with possible variables and expansions) but not to create files where I do not put it explicitly into a code block. These wrappers have nothing to do with the code, and are only there for the exported engine. So I would either revert to the original behavior, or, introduce a new header argument, e.g. :include-wrappers, which would, if set to t, include the export wrappers in the tangled file. This might be useful for debugging exporting of code block results, but not for general tangling. Cheers, Rainer > > Best, > >> >> >> John >> >>> Best, >>> >>> -- >>> Eric Schulte >>> https://cs.unm.edu/~eschulte >>> PGP: 0x614CA05D -- Rainer M. Krug email: RMKruggmailcom pgpbTlCE4agPe.pgp Description: PGP signature
Re: [O] [BABEL] BUG Re: Omitting try/catch blocks from tangled R code?
John Hendy writes: > On Mon, Mar 17, 2014 at 10:00 AM, Eric Schulte wrote: >> John Hendy writes: >> >>> On Fri, Feb 7, 2014 at 1:22 PM, Rainer M Krug wrote: On 02/07/14, 17:47 , Eric Schulte wrote: > Rainer M Krug writes: > >> On 02/07/14, 07:18 , John Hendy wrote: >>> Greetings, >>> >>> >>> I don't usually tangle, but am creating a code file to go along with a >>> presentation I'm giving this weekend so that attendees can try things >>> out afterward by cloning my github repo where all the data and >>> necessary files are stored. >>> >>> In my presentation (Beamer), I create plots via the R pdf() device, >>> and noticed that all of the tangled code where plots are generated >>> contains the following: >>> >>> pdf(file="file.pdf"); tryCatch({ >>> >>> code block contents here >>> >>> },error=function(e){plot(x=-1:1, y=-1:1, type='n', xlab='', ylab='', >>> axes=FALSE); text(x=0, y=0, labels=e$message, col='red'); >>> paste('ERROR', e$message, sep=' : ')}); dev.off() >>> >>> Is there a way to omit this? >> >> This is a bug which must have been introduced some time ago - in the >> stock version of emacs (Org-mode version 7.9.3f >> (release_7.9.3f-17-g7524ef @ >> /usr/local/Cellar/emacs/24.3/share/emacs/24.3/lisp/org/)) it does not >> tangle the enclosing commands to create graphics, but in 8.2 it does (I >> don't have an older version at hand to go further back). >> > > I believe this was introduced by your commit eaa3a761d. Reversion of > which with the following should provide a temporary workaround. >> >> I take this back, the behavior is unrelated to Rainer's commit adding >> try/catch blocks to R graphics creation logic. >> >> In fact I don't believe this is a bug, rather the default behavior is to >> expand code block bodies on tangling. This behavior may be changed by >> using the :no-expand header argument which will inhibit code block body >> expansion during tangling. >> > > Got it, and thanks for the new variable tip! > > Out of curiosity, is there a consensus that this is the preferred > behavior for tangling by default? There may have been a consensus in a single thread motivated by a single use case, which should not necessarily be a global consensus. > I'm guessing at some point it was decided that the need was preferred > to have these bits inserted before/after code blocks, but just trying > to confirm this. It seems odd to me, at least given R's behavior, that > someone would prefer these bits to show up in the tangled file since > they appeared to serve the purpose of having Org not fail during > export vs. benefitting the code in any way (if I wasn't running code > through R, I'd just get the errors directly). > I'd be happy to add :no-expand to the default R header arguments. Or even to change this behavior globally, if the current behavior is universally surprising. Best, > > > John > >> Best, >> >> -- >> Eric Schulte >> https://cs.unm.edu/~eschulte >> PGP: 0x614CA05D -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D
Re: [O] [BABEL] BUG Re: Omitting try/catch blocks from tangled R code?
On Mon, Mar 17, 2014 at 10:00 AM, Eric Schulte wrote: > John Hendy writes: > >> On Fri, Feb 7, 2014 at 1:22 PM, Rainer M Krug wrote: >>> >>> >>> >>> On 02/07/14, 17:47 , Eric Schulte wrote: >>> > Rainer M Krug writes: >>> > >>> >> On 02/07/14, 07:18 , John Hendy wrote: >>> >>> Greetings, >>> >>> >>> >>> >>> >>> I don't usually tangle, but am creating a code file to go along with a >>> >>> presentation I'm giving this weekend so that attendees can try things >>> >>> out afterward by cloning my github repo where all the data and >>> >>> necessary files are stored. >>> >>> >>> >>> In my presentation (Beamer), I create plots via the R pdf() device, >>> >>> and noticed that all of the tangled code where plots are generated >>> >>> contains the following: >>> >>> >>> >>> pdf(file="file.pdf"); tryCatch({ >>> >>> >>> >>> code block contents here >>> >>> >>> >>> },error=function(e){plot(x=-1:1, y=-1:1, type='n', xlab='', ylab='', >>> >>> axes=FALSE); text(x=0, y=0, labels=e$message, col='red'); >>> >>> paste('ERROR', e$message, sep=' : ')}); dev.off() >>> >>> >>> >>> Is there a way to omit this? >>> >> >>> >> This is a bug which must have been introduced some time ago - in the >>> >> stock version of emacs (Org-mode version 7.9.3f >>> >> (release_7.9.3f-17-g7524ef @ >>> >> /usr/local/Cellar/emacs/24.3/share/emacs/24.3/lisp/org/)) it does not >>> >> tangle the enclosing commands to create graphics, but in 8.2 it does (I >>> >> don't have an older version at hand to go further back). >>> >> >>> > >>> > I believe this was introduced by your commit eaa3a761d. Reversion of >>> > which with the following should provide a temporary workaround. >>> > > I take this back, the behavior is unrelated to Rainer's commit adding > try/catch blocks to R graphics creation logic. > > In fact I don't believe this is a bug, rather the default behavior is to > expand code block bodies on tangling. This behavior may be changed by > using the :no-expand header argument which will inhibit code block body > expansion during tangling. > Got it, and thanks for the new variable tip! Out of curiosity, is there a consensus that this is the preferred behavior for tangling by default? I'm guessing at some point it was decided that the need was preferred to have these bits inserted before/after code blocks, but just trying to confirm this. It seems odd to me, at least given R's behavior, that someone would prefer these bits to show up in the tangled file since they appeared to serve the purpose of having Org not fail during export vs. benefitting the code in any way (if I wasn't running code through R, I'd just get the errors directly). John > Best, > > -- > Eric Schulte > https://cs.unm.edu/~eschulte > PGP: 0x614CA05D
Re: [O] [BABEL] BUG Re: Omitting try/catch blocks from tangled R code?
John Hendy writes: > On Fri, Feb 7, 2014 at 1:22 PM, Rainer M Krug wrote: >> >> >> >> On 02/07/14, 17:47 , Eric Schulte wrote: >> > Rainer M Krug writes: >> > >> >> On 02/07/14, 07:18 , John Hendy wrote: >> >>> Greetings, >> >>> >> >>> >> >>> I don't usually tangle, but am creating a code file to go along with a >> >>> presentation I'm giving this weekend so that attendees can try things >> >>> out afterward by cloning my github repo where all the data and >> >>> necessary files are stored. >> >>> >> >>> In my presentation (Beamer), I create plots via the R pdf() device, >> >>> and noticed that all of the tangled code where plots are generated >> >>> contains the following: >> >>> >> >>> pdf(file="file.pdf"); tryCatch({ >> >>> >> >>> code block contents here >> >>> >> >>> },error=function(e){plot(x=-1:1, y=-1:1, type='n', xlab='', ylab='', >> >>> axes=FALSE); text(x=0, y=0, labels=e$message, col='red'); >> >>> paste('ERROR', e$message, sep=' : ')}); dev.off() >> >>> >> >>> Is there a way to omit this? >> >> >> >> This is a bug which must have been introduced some time ago - in the >> >> stock version of emacs (Org-mode version 7.9.3f >> >> (release_7.9.3f-17-g7524ef @ >> >> /usr/local/Cellar/emacs/24.3/share/emacs/24.3/lisp/org/)) it does not >> >> tangle the enclosing commands to create graphics, but in 8.2 it does (I >> >> don't have an older version at hand to go further back). >> >> >> > >> > I believe this was introduced by your commit eaa3a761d. Reversion of >> > which with the following should provide a temporary workaround. >> I take this back, the behavior is unrelated to Rainer's commit adding try/catch blocks to R graphics creation logic. In fact I don't believe this is a bug, rather the default behavior is to expand code block bodies on tangling. This behavior may be changed by using the :no-expand header argument which will inhibit code block body expansion during tangling. Best, -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D
Re: [O] [BABEL] BUG Re: Omitting try/catch blocks from tangled R code?
On Fri, Feb 7, 2014 at 1:22 PM, Rainer M Krug wrote: > > > > On 02/07/14, 17:47 , Eric Schulte wrote: > > Rainer M Krug writes: > > > >> On 02/07/14, 07:18 , John Hendy wrote: > >>> Greetings, > >>> > >>> > >>> I don't usually tangle, but am creating a code file to go along with a > >>> presentation I'm giving this weekend so that attendees can try things > >>> out afterward by cloning my github repo where all the data and > >>> necessary files are stored. > >>> > >>> In my presentation (Beamer), I create plots via the R pdf() device, > >>> and noticed that all of the tangled code where plots are generated > >>> contains the following: > >>> > >>> pdf(file="file.pdf"); tryCatch({ > >>> > >>> code block contents here > >>> > >>> },error=function(e){plot(x=-1:1, y=-1:1, type='n', xlab='', ylab='', > >>> axes=FALSE); text(x=0, y=0, labels=e$message, col='red'); > >>> paste('ERROR', e$message, sep=' : ')}); dev.off() > >>> > >>> Is there a way to omit this? > >> > >> This is a bug which must have been introduced some time ago - in the > >> stock version of emacs (Org-mode version 7.9.3f > >> (release_7.9.3f-17-g7524ef @ > >> /usr/local/Cellar/emacs/24.3/share/emacs/24.3/lisp/org/)) it does not > >> tangle the enclosing commands to create graphics, but in 8.2 it does (I > >> don't have an older version at hand to go further back). > >> > > > > I believe this was introduced by your commit eaa3a761d. Reversion of > > which with the following should provide a temporary workaround. > > I checked it with version 8.2, which was, as far as I remember, before > my change of the R code to include the error handling, and the pdf(...) > ... dev.off() was in the tangled file as well - so the behaviour must > have been introduced earlier. The only change I did was to change the R > code, so no change in the behavior if it is tangled or not. > > I will look at it again on Monday to go back through the released > versions to narrow down where this had changed. > > Just following up on this to see if the current behavior is desired or if, indeed, something should/could change. Thanks! John > > > > git revert eaa3a761d > > I don't think that this actually changes much - only that the enclosing > code will become pdf(...) THE CODE dev.off() > > Cheers, > > Rainer > > > > > Perhaps the try/catch code should be moved from org-babel-expand-body:R > > to org-babel-execute:R. Alternately, the code should stay as is and you > > should use the no-expand header argument during tangling. > > > > I'm not sure which makes the most sense, but I'd lean towards the > > former. > > > > Best, > > > >> > >>> > >>> I'm guessing this is here to create a blank plot with the error as the > >>> output when something goes awry? > >> > >> Yes. > >> > >>> > >>> I checked around variable completions of org-babel-tangle-* and > >>> searched google for terms like "org babel tangle try catch" but am not > >>> finding anything that looks like what I need. > >> > >> There is nothing, as it should not be tangled. The enclosing commands > >> concern the export, but not tangling, > >> > >> I agree that the :result graphics header argument caused commands should > >> not be in the tangled file. > >> > >> Another question is about the :epilogue and :prologue which I think > >> should be present (haven't checked if they are...). > >> > >> Cheers, > >> > >> Rainer > >> > >> > >>> > >>> > >>> Thanks, > >>> John > >>> > > > > -- > 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: rai...@krugs.de > > Skype: RMkrug >
Re: [O] [BABEL] BUG Re: Omitting try/catch blocks from tangled R code?
On 02/07/14, 17:47 , Eric Schulte wrote: > Rainer M Krug writes: > >> On 02/07/14, 07:18 , John Hendy wrote: >>> Greetings, >>> >>> >>> I don't usually tangle, but am creating a code file to go along with a >>> presentation I'm giving this weekend so that attendees can try things >>> out afterward by cloning my github repo where all the data and >>> necessary files are stored. >>> >>> In my presentation (Beamer), I create plots via the R pdf() device, >>> and noticed that all of the tangled code where plots are generated >>> contains the following: >>> >>> pdf(file="file.pdf"); tryCatch({ >>> >>> code block contents here >>> >>> },error=function(e){plot(x=-1:1, y=-1:1, type='n', xlab='', ylab='', >>> axes=FALSE); text(x=0, y=0, labels=e$message, col='red'); >>> paste('ERROR', e$message, sep=' : ')}); dev.off() >>> >>> Is there a way to omit this? >> >> This is a bug which must have been introduced some time ago - in the >> stock version of emacs (Org-mode version 7.9.3f >> (release_7.9.3f-17-g7524ef @ >> /usr/local/Cellar/emacs/24.3/share/emacs/24.3/lisp/org/)) it does not >> tangle the enclosing commands to create graphics, but in 8.2 it does (I >> don't have an older version at hand to go further back). >> > > I believe this was introduced by your commit eaa3a761d. Reversion of > which with the following should provide a temporary workaround. I checked it with version 8.2, which was, as far as I remember, before my change of the R code to include the error handling, and the pdf(...) ... dev.off() was in the tangled file as well - so the behaviour must have been introduced earlier. The only change I did was to change the R code, so no change in the behavior if it is tangled or not. I will look at it again on Monday to go back through the released versions to narrow down where this had changed. > > git revert eaa3a761d I don't think that this actually changes much - only that the enclosing code will become pdf(...) THE CODE dev.off() Cheers, Rainer > > Perhaps the try/catch code should be moved from org-babel-expand-body:R > to org-babel-execute:R. Alternately, the code should stay as is and you > should use the no-expand header argument during tangling. > > I'm not sure which makes the most sense, but I'd lean towards the > former. > > Best, > >> >>> >>> I'm guessing this is here to create a blank plot with the error as the >>> output when something goes awry? >> >> Yes. >> >>> >>> I checked around variable completions of org-babel-tangle-* and >>> searched google for terms like "org babel tangle try catch" but am not >>> finding anything that looks like what I need. >> >> There is nothing, as it should not be tangled. The enclosing commands >> concern the export, but not tangling, >> >> I agree that the :result graphics header argument caused commands should >> not be in the tangled file. >> >> Another question is about the :epilogue and :prologue which I think >> should be present (haven't checked if they are...). >> >> Cheers, >> >> Rainer >> >> >>> >>> >>> Thanks, >>> John >>> > -- 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: rai...@krugs.de Skype: RMkrug signature.asc Description: OpenPGP digital signature
Re: [O] [BABEL] BUG Re: Omitting try/catch blocks from tangled R code?
Rainer M Krug writes: > On 02/07/14, 07:18 , John Hendy wrote: >> Greetings, >> >> >> I don't usually tangle, but am creating a code file to go along with a >> presentation I'm giving this weekend so that attendees can try things >> out afterward by cloning my github repo where all the data and >> necessary files are stored. >> >> In my presentation (Beamer), I create plots via the R pdf() device, >> and noticed that all of the tangled code where plots are generated >> contains the following: >> >> pdf(file="file.pdf"); tryCatch({ >> >> code block contents here >> >> },error=function(e){plot(x=-1:1, y=-1:1, type='n', xlab='', ylab='', >> axes=FALSE); text(x=0, y=0, labels=e$message, col='red'); >> paste('ERROR', e$message, sep=' : ')}); dev.off() >> >> Is there a way to omit this? > > This is a bug which must have been introduced some time ago - in the > stock version of emacs (Org-mode version 7.9.3f > (release_7.9.3f-17-g7524ef @ > /usr/local/Cellar/emacs/24.3/share/emacs/24.3/lisp/org/)) it does not > tangle the enclosing commands to create graphics, but in 8.2 it does (I > don't have an older version at hand to go further back). > I believe this was introduced by your commit eaa3a761d. Reversion of which with the following should provide a temporary workaround. git revert eaa3a761d Perhaps the try/catch code should be moved from org-babel-expand-body:R to org-babel-execute:R. Alternately, the code should stay as is and you should use the no-expand header argument during tangling. I'm not sure which makes the most sense, but I'd lean towards the former. Best, > >> >> I'm guessing this is here to create a blank plot with the error as the >> output when something goes awry? > > Yes. > >> >> I checked around variable completions of org-babel-tangle-* and >> searched google for terms like "org babel tangle try catch" but am not >> finding anything that looks like what I need. > > There is nothing, as it should not be tangled. The enclosing commands > concern the export, but not tangling, > > I agree that the :result graphics header argument caused commands should > not be in the tangled file. > > Another question is about the :epilogue and :prologue which I think > should be present (haven't checked if they are...). > > Cheers, > > Rainer > > >> >> >> Thanks, >> John >> -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D
[O] [BABEL] BUG Re: Omitting try/catch blocks from tangled R code?
On 02/07/14, 07:18 , John Hendy wrote: > Greetings, > > > I don't usually tangle, but am creating a code file to go along with a > presentation I'm giving this weekend so that attendees can try things > out afterward by cloning my github repo where all the data and > necessary files are stored. > > In my presentation (Beamer), I create plots via the R pdf() device, > and noticed that all of the tangled code where plots are generated > contains the following: > > pdf(file="file.pdf"); tryCatch({ > > code block contents here > > },error=function(e){plot(x=-1:1, y=-1:1, type='n', xlab='', ylab='', > axes=FALSE); text(x=0, y=0, labels=e$message, col='red'); > paste('ERROR', e$message, sep=' : ')}); dev.off() > > Is there a way to omit this? This is a bug which must have been introduced some time ago - in the stock version of emacs (Org-mode version 7.9.3f (release_7.9.3f-17-g7524ef @ /usr/local/Cellar/emacs/24.3/share/emacs/24.3/lisp/org/)) it does not tangle the enclosing commands to create graphics, but in 8.2 it does (I don't have an older version at hand to go further back). > > I'm guessing this is here to create a blank plot with the error as the > output when something goes awry? Yes. > > I checked around variable completions of org-babel-tangle-* and > searched google for terms like "org babel tangle try catch" but am not > finding anything that looks like what I need. There is nothing, as it should not be tangled. The enclosing commands concern the export, but not tangling, I agree that the :result graphics header argument caused commands should not be in the tangled file. Another question is about the :epilogue and :prologue which I think should be present (haven't checked if they are...). Cheers, Rainer > > > Thanks, > John > -- 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: rai...@krugs.de Skype: RMkrug signature.asc Description: OpenPGP digital signature