From: Rainer M Krug <Rainer@krugs.de>
To: Eric Schulte <schulte.eric@gmail.com>
Cc: emacs-orgmode@gnu.org, Charles Berry <ccberry@ucsd.edu>
Subject: Re: [BABEL] BUG Re: Omitting try/catch blocks from tangled R code?
Date: Fri, 28 Mar 2014 09:51:09 +0100 [thread overview]
Message-ID: <m2bnwqvh8i.fsf@krugs.de> (raw)
In-Reply-To: <87d2h71qqc.fsf@bagel.gateway.pace.com> (Eric Schulte's message of "Wed, 26 Mar 2014 16:17:50 -0400")
[-- Attachment #1: Type: text/plain, Size: 11898 bytes --]
Eric Schulte <schulte.eric@gmail.com> writes:
> Rainer M Krug <Rainer@krugs.de> writes:
>
>> Eric Schulte <schulte.eric@gmail.com> writes:
>>
>>> Rainer M Krug <Rainer@krugs.de> writes:
>>>
>>>> Eric Schulte <schulte.eric@gmail.com> writes:
>>>>
>>>>> Rainer M Krug <Rainer@krugs.de> writes:
>>>>>
>>>>>> Eric Schulte <schulte.eric@gmail.com> writes:
>>>>>>
>>>>>>> Charles Berry <ccberry@ucsd.edu> writes:
>>>>>>>
>>>>>>>> John Hendy <jw.hendy <at> 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: Rainer@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/wcr5bjwn75q595n6x82gxj280000gn/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/wcr5bjwn75q595n6x82gxj280000gn/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/wcr5bjwn75q595n6x82gxj280000gn/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/wcr5bjwn75q595n6x82gxj280000gn/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/wcr5bjwn75q595n6x82gxj280000gn/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.rds\"\nIFNCOUNT <-
>> | \"./__BOX__/IFN/DB_IFN/rdsRasterized/tabplot.count.8km.rds\"\nIFNMEAN
>> | <-
>> | \"./__BOX__/IFN/DB_IFN/rdsRasterized/tabplot.mean.8km.rds\"\nIFNPRES
>> | <-
>> | \"./__BOX__/IFN/DB_IFN/rdsRasterized/tabplot.pres.8km.rds\"\nIFNSD
>> | <-
>> | \"./__BOX__/IFN/DB_IFN/rdsRasterized/tabplot.sd.8km.rds\"\nIFNTABTREE
>> | <- \"./__BOX__/IFN/DB_IFN/rds/tabtree.rds\"\ndata.sources <-
>> | list.files(\"./data\", pattern=\"*.rda$\",
>> | full.names=TRUE)\nR.sources <- list.files(\"./R\", pattern=\"*.R$\",
>> | full.names=TRUE)\ncat(\"Loading Data\\n\")\nas.vector( sapply(
>> | data.sources, load) )\ncat(\"\\nSourcing R files\\n\")\nsapply(
>> | R.sources, source)" "\n")
>> | org-babel-execute:R("data.sources <- list.files(\"./data\",
>> | pattern=\"*.rda$\", full.names=TRUE)\nR.sources <-
>> | list.files(\"./R\", pattern=\"*.R$\",
>> | full.names=TRUE)\ncat(\"Loading Data\\n\")\nas.vector( sapply(
>> | data.sources, load) )\ncat(\"\\nSourcing R files\\n\")\nsapply(
>> | R.sources, source)" ((:comments . "link") (:shebang . "") (:cache
>> | . "no") (:padline . "yes") (:noweb . "no") (:tangle . "yes")
>> | (:exports . "both") (:results . "replace output") (:var COLUMNS
>> | ("annee" "Year of simulation") ("ipoints_Qdiv" "Point Number (also
>> | refer to number of the climatic input file)") ("iespece" "species
>> | number (4==>Beech; 3:Oak)") ("scenario" "Type of forest management
>> | (no matter)") ("climat" "Type of climate (no matter)") ("RUsolinit"
>> | "Soil water Holding Capacity of the point (mm)") ("PByC" "gross
>> | photosynthesis (yearly, gC/m²/year)") ("PNyC" "Net photosynthesis,
>> | (PByC - leaf Respiration) (gC/m²/year)") ("NPPyC" "Net primary
>> | productivity, (gC/m²/year)") ("ETRy" "Evapotranspiration of stand
>> | (mm/year)") ("age_peup" "Age at the end of the revolution") ("RVy"
>> | "total respiration of living tissue") ("DBBVy" "aboveground annualm
>> | growth (gC/m²/year)") ("RMTVy" "maintenance respiration of stems
>> | (gC/m²/year)") ("RMBRy" "maintenance respiration of branches
>> | (gC/m²/year)") ("Rtoty" "total heterotrophic respiration
>> | (gC/m²/year) (SOIL)") ("levelstress_2" "indices of water stress
>> | based on stomatal conductance") ("Ta" "Annual Temperature (°C) (do
>> | not use problem)") ("PRI" "Rain (mm) (do not use problem)") ("LMAX"
>> | "Leaf Area Index") ("RVCy" "Growth respiration of living tissue")
>> | ("RVMy" "Maintenance respiration of all living tissue") ("DBSSy"
>> | "annual storage growth (gc/m²/year)") ("DBRFy" "annual fine roots
>> | growth (gC/m²/year)") ("LambX" "X co,ordinates in Lamberts Zone II
>> | (EPSG 27572)") ("LambY" "Y co,ordinates in Lamberts Zone II (EPSG
>> | 27572)") ("Altitude" "Elevation(m)") ("coupebb" "exported biomass
>> | through cutting (gC/m²)") ("bbois" "wood biomass of the stand
>> | (gC/m²)")) (:var COLS_TO_EVAL ("NPPyC" "FALSE") ("DBBVy" "TRUE")
>> | ("DBRFy" "FALSE") ("DBSSy" "FALSE") ("levelstress_2" "TRUE")) (:var
>> | ALLSPECIES ("Quercus robur" 1 "quercus_robur" "") ("Quercus peatrea"
>> | 2 "quercus_peatrea" "") ("Quercus pubescens" 3 "quercus_pubescens"
>> | "") ("Fagus sylvatica" 4 "fagus_sylvatica" "") ("Carpinus betulus" 5
>> | "carpinus_betulus" "") ("Other broadleaf species" 6
>> | "other_broadleaf_species" "") ("Picae abies" 7 "picae_abies" "")
>> | ("Abies alba" 8 "abies_alba" "") ("Pinus maritima" 9
>> | "pinus_maritima" "") ("Pinus sylvestris" 10 "pinus_sylvestris" "")
>> | ("pseudotsuga meniezi" 11 "pseudotsuga_meniezi" "") ("Other
>> | coniferous species" 12 "other_coniferous_species" "")) (:var SPECIES
>> | ("Fagus sylvatica" "fagus" 4 "fagus_sylvatica" "red") ("Quercus
>> | robur" "quercus" 3 "quercus_robur" "green")) (:var YEARS (1990)
>> | (2000)) (:var PRESENT . 2008) (:var MINEFFORT . 3) (:var PROPTRAIN
>> | . 0.6) (:var RNGSEED . 13) (:var RNGKIND . "Mersenne-Twister") (:var
>> | RNGNORMALKIND . "Inversion") (:var REFGRID . "./refGrid_8km.rds")
>> | (:var IFN . "./__BOX__/IFN/DB_IFN/rds/tabplot.rds") (:var IFNCOUNT
>> | . "./__BOX__/IFN/DB_IFN/rdsRasterized/tabplot.count.8km.rds") (:var
>> | IFNMEAN . "./__BOX__/IFN/DB_IFN/rdsRasterized/tabplot.mean.8km.rds")
>> | (:var IFNPRES
>> | . "./__BOX__/IFN/DB_IFN/rdsRasterized/tabplot.pres.8km.rds") (:var
>> | IFNSD . "./__BOX__/IFN/DB_IFN/rdsRasterized/tabplot.sd.8km.rds")
>> | (:var IFNTABTREE . "./__BOX__/IFN/DB_IFN/rds/tabtree.rds") (:hlines
>> | . "no") (:colnames . "yes") (:mkdirp . "yes") (:no-expand . "TRUE")
>> | (:rownames . "yes") (:session . "*R_MOBILIS*") (:tangle-mode . 292)
>> | (:result-type . output) (:result-params "output" "replace")
>> | (:rowname-names (COLUMNS "annee" "ipoints_Qdiv" "iespece" "scenario"
>> | "climat" "RUsolinit" "PByC" "PNyC" "NPPyC" "ETRy" "age_peup" "RVy"
>> | "DBBVy" "RMTVy" "RMBRy" "Rtoty" "levelstress_2" "Ta" "PRI" "LMAX"
>> | "RVCy" "RVMy" "DBSSy" "DBRFy" "LambX" "LambY" "Altitude" "coupebb"
>> | "bbois") (COLS_TO_EVAL 1 2 3 4 5) (ALLSPECIES 1 2 3 4 5 6 7 8 9 10
>> | 11 12) (SPECIES "fagus" "quercus") (YEARS 1 2)) (:colname-names
>> | (COLUMNS "" "name" "description") (COLS_TO_EVAL "" "name" "usable")
>> | (ALLSPECIES "" "fullName" "iespece" "IFNName" "color") (SPECIES ""
>> | "fullName" "shortName" "iespece" "IFNName" "color") (YEARS ""
>> | "year"))))
>> | org-babel-execute-src-block(nil)
>> | org-babel-execute-buffer(nil)
>> | org-babel-execute-subtree(nil)
>> | call-interactively(org-babel-execute-subtree nil nil)
>> `----
>>
>> Cheers,
>>
>> Rainer
>>
>>>
>>> Best,
>>>
> p>>>
>>>> Thanks,
>>>>
>>>> Rainer
>>>>
>>>>>
>>>>> Thanks,
--
Rainer M. Krug
email: Rainer<at>krugs<dot>de
PGP: 0x0F52F982
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 4474 bytes --]
next prev parent reply other threads:[~2014-03-28 8:51 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-07 6:18 Omitting try/catch blocks from tangled R code? John Hendy
2014-02-07 8:26 ` [BABEL] BUG " Rainer M Krug
2014-02-07 16:47 ` Eric Schulte
2014-02-07 19:22 ` Rainer M Krug
2014-03-12 1:13 ` John Hendy
2014-03-17 15:00 ` Eric Schulte
2014-03-17 17:11 ` John Hendy
2014-03-17 17:44 ` Eric Schulte
2014-03-18 8:44 ` Rainer M Krug
2014-03-18 21:56 ` John Hendy
2014-03-19 19:07 ` Charles Berry
2014-03-20 4:57 ` Eric Schulte
2014-03-20 9:22 ` Rainer M Krug
2014-03-24 2:03 ` Eric Schulte
2014-03-24 10:22 ` Rainer M Krug
2014-03-24 13:16 ` Eric Schulte
2014-03-25 9:37 ` Rainer M Krug
2014-03-26 20:17 ` Eric Schulte
2014-03-28 8:32 ` Rainer M Krug
2014-03-28 8:51 ` Rainer M Krug [this message]
2014-03-30 14:19 ` Eric Schulte
2014-03-31 7:52 ` Rainer M Krug
2014-04-02 23:09 ` Eric Schulte
2014-04-07 7:59 ` Rainer M Krug
2014-04-11 2:35 ` Eric Schulte
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=m2bnwqvh8i.fsf@krugs.de \
--to=rainer@krugs.de \
--cc=ccberry@ucsd.edu \
--cc=emacs-orgmode@gnu.org \
--cc=schulte.eric@gmail.com \
/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).