From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rainer M Krug Subject: Re: [BABEL] BUG Re: Omitting try/catch blocks from tangled R code? Date: Tue, 25 Mar 2014 10:37:24 +0100 Message-ID: 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> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:60808) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WSNnd-0003cH-Al for emacs-orgmode@gnu.org; Tue, 25 Mar 2014 05:37:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WSNnX-0005Qk-MZ for emacs-orgmode@gnu.org; Tue, 25 Mar 2014 05:37:37 -0400 Received: from mail-wi0-f181.google.com ([209.85.212.181]:57116) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WSNnX-0005Qf-Cn for emacs-orgmode@gnu.org; Tue, 25 Mar 2014 05:37:31 -0400 Received: by mail-wi0-f181.google.com with SMTP id hm4so395467wib.14 for ; Tue, 25 Mar 2014 02:37:30 -0700 (PDT) In-Reply-To: <87siq7g2j5.fsf@gmail.com> (Eric Schulte's message of "Mon, 24 Mar 2014 07:16:30 -0600") 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: Eric Schulte Cc: emacs-orgmode@gnu.org, Charles Berry --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 variab= les and >>>>>>> > expansions) but not to create files where I do not put it explici= tly >>>>>>> > into a code block. These wrappers have nothing to do with the cod= e, 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 exp= ort >>>>>>> > wrappers in the tangled file. This might be useful for debugging >>>>>>> > exporting of code block results, but not for general tangling. >>>>>>>=20 >>>>>>> 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 tang= le, >>>>>>> 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 e= xport >>>>>> them and in others I just tangle them. >>>>>> >>>>>> I hope that the revised code will allow me to turn off try/catch wra= pping >>>>>> and still be able to use noweb when tangling or exporting. >>>>>> >>>>> >>>>> In addition to noweb, there are cases where variable expansion is use= ful >>>>> 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=20 Org-mode version 8.2.5h (release_8.2.5h-846-geb806d @ /Users/rainerkrug/.em= acs.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/wcr5bjwn75q= 595n6x82gxj280000gn/T/babel-21363l1U/R-import-21363S9b\",\n = header=3DTRUE,\n row.names=3D1,\n = sep=3D\"\\t\",\n as.is=3DTRUE)\nCOLS_TO_EVAL <-= read.table(\"/var/folders/50/wcr5bjwn75q595n6x82gxj280000gn/T/babel-21363l= 1U/R-import-21363fHi\",\n header=3DTRUE,\n = row.names=3D1,\n sep=3D\"\\t\",\n = as.is=3DTRUE)\nALLSPECIES <- read.table(\"/var/folders/50/wcr5bj= wn75q595n6x82gxj280000gn/T/babel-21363l1U/R-import-21363sRo\",\n = header=3DTRUE,\n row.names=3D1,\n = sep=3D\"\\t\",\n as.is=3DTRUE)\nSPECIES <-= read.table(\"/var/folders/50/wcr5bjwn75q595n6x82gxj280000gn/T/babel-21363l= 1U/R-import-213635bu\",\n header=3DTRUE,\n = row.names=3D1,\n sep=3D\"\\t\",\n = as.is=3DTRUE)\nYEARS <- read.table(\"/var/folders/50/wcr5bjwn75q= 595n6x82gxj280000gn/T/babel-21363l1U/R-import-21363Gm0\",\n = header=3DTRUE,\n row.names=3D1,\n = sep=3D\"\\t\",\n as.is=3DTRUE)\nPRESENT <- 2008= \nMINEFFORT <- 3\nPROPTRAIN <- 0.6\nRNGSEED <- 13\nRNGKIND <- \"Mersenne-Tw= ister\"\nRNGNORMALKIND <- \"Inversion\"\nREFGRID <- \"./refGrid_8km.rds\"\n= IFN <- \"./__BOX__/IFN/DB_IFN/rds/tabplot.rds\"\nIFNCOUNT <- \"./__BOX__/IF= N/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/r= dsRasterized/tabplot.sd.8km.rds\"\nIFNTABTREE <- \"./__BOX__/IFN/DB_IFN/rds= /tabtree.rds\"\ndata.sources <- list.files(\"./data\", pattern=3D\"*.rda$\"= , full.names=3DTRUE)\nR.sources <- list.files(\"./R\", pattern=3D\"*.R$\", = full.names=3DTRUE)\ncat(\"Loading Data\\n\")\nas.vector( sapply( data.sourc= es, load) )\ncat(\"\\nSourcing R files\\n\")\nsapply( R.sources, source)" "= \n") | org-babel-execute:R("data.sources <- list.files(\"./data\", pattern=3D\= "*.rda$\", full.names=3DTRUE)\nR.sources <- list.files(\"./R\", pattern=3D\= "*.R$\", full.names=3DTRUE)\ncat(\"Loading Data\\n\")\nas.vector( sapply( d= ata.sources, load) )\ncat(\"\\nSourcing R files\\n\")\nsapply( R.sources, s= ource)" ((:comments . "link") (:shebang . "") (:cache . "no") (:padline . "= yes") (:noweb . "no") (:tangle . "yes") (:exports . "both") (:results . "re= place output") (:var COLUMNS ("annee" "Year of simulation") ("ipoints_Qdiv"= "Point Number (also refer to number of the climatic input file)") ("iespec= e" "species number (4=3D=3D>Beech; 3:Oak)") ("scenario" "Type of forest man= agement (no matter)") ("climat" "Type of climate (no matter)") ("RUsolinit"= "Soil water Holding Capacity of the point (mm)") ("PByC" "gross photosynth= esis (yearly, gC/m=C2=B2/year)") ("PNyC" "Net photosynthesis, (PByC - leaf = Respiration) (gC/m=C2=B2/year)") ("NPPyC" "Net primary productivity, (gC/m= =C2=B2/year)") ("ETRy" "Evapotranspiration of stand (mm/year)") ("age_peup"= "Age at the end of the revolution") ("RVy" "total respiration of living ti= ssue") ("DBBVy" "aboveground annualm growth (gC/m=C2=B2/year)") ("RMTVy" "m= aintenance respiration of stems (gC/m=C2=B2/year)") ("RMBRy" "maintenance r= espiration of branches (gC/m=C2=B2/year)") ("Rtoty" "total heterotrophic re= spiration (gC/m=C2=B2/year) (SOIL)") ("levelstress_2" "indices of water str= ess based on stomatal conductance") ("Ta" "Annual Temperature (=C2=B0C) (do= not use problem)") ("PRI" "Rain (mm) (do not use problem)") ("LMAX" "Leaf = Area Index") ("RVCy" "Growth respiration of living tissue") ("RVMy" "Mainte= nance respiration of all living tissue") ("DBSSy" "annual storage growth (g= c/m=C2=B2/year)") ("DBRFy" "annual fine roots growth (gC/m=C2=B2/year)") ("= LambX" "X co,ordinates in Lamberts Zone II (EPSG 27572)") ("LambY" "Y co,or= dinates in Lamberts Zone II (EPSG 27572)") ("Altitude" "Elevation(m)") ("co= upebb" "exported biomass through cutting (gC/m=C2=B2)") ("bbois" "wood biom= ass of the stand (gC/m=C2=B2)")) (:var COLS_TO_EVAL ("NPPyC" "FALSE") ("DBB= Vy" "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" "") ("Fag= us sylvatica" 4 "fagus_sylvatica" "") ("Carpinus betulus" 5 "carpinus_betul= us" "") ("Other broadleaf species" 6 "other_broadleaf_species" "") ("Picae = abies" 7 "picae_abies" "") ("Abies alba" 8 "abies_alba" "") ("Pinus maritim= a" 9 "pinus_maritima" "") ("Pinus sylvestris" 10 "pinus_sylvestris" "") ("p= seudotsuga meniezi" 11 "pseudotsuga_meniezi" "") ("Other coniferous species= " 12 "other_coniferous_species" "")) (:var SPECIES ("Fagus sylvatica" "fagu= s" 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-T= wister") (: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" "iespec= e" "scenario" "climat" "RUsolinit" "PByC" "PNyC" "NPPyC" "ETRy" "age_peup" = "RVy" "DBBVy" "RMTVy" "RMBRy" "Rtoty" "levelstress_2" "Ta" "PRI" "LMAX" "RV= Cy" "RVMy" "DBSSy" "DBRFy" "LambX" "LambY" "Altitude" "coupebb" "bbois") (C= OLS_TO_EVAL 1 2 3 4 5) (ALLSPECIES 1 2 3 4 5 6 7 8 9 10 11 12) (SPECIES "fa= gus" "quercus") (YEARS 1 2)) (:colname-names (COLUMNS "" "name" "descriptio= n") (COLS_TO_EVAL "" "name" "usable") (ALLSPECIES "" "fullName" "iespece" "= IFNName" "color") (SPECIES "" "fullName" "shortName" "iespece" "IFNName" "c= olor") (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, > >> >> Thanks, >> >> Rainer >> >>> >>> Thanks, =2D-=20 Rainer M. Krug email: Rainerkrugsde PGP: 0x0F52F982 --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.22 (Darwin) iQEcBAEBAgAGBQJTMU5YAAoJENvXNx4PUvmCZqIH/iyym2aodtqsBmBDgpaxARzb UB3BzADYHRmjwCVdalTbeHkjsU6FFDDfTa3OgbeLr5beF/462wZIrOvhCJD8kp3u kPlFSpl4UypNQF/Xpg6jL3K73xtX5MSEh8X1RgrR9znl5R+i0ov2xrxx/AWvXl83 uh37t4xPq7QCiWyuDpLVuaN39i7KtBbyBk/vkuvHuFKO4xW7anAiMLZNEjDGYXki Si9y5ABizuqBnKFHGBINWEL798IzAVSDN8xKePdkWBdSn27bn/pAFI1rEDEN6UbW 6MZ7/EPWpBLT3VO7QhdCYHuHaH2zJnhL9QSzj7p76HbZ6M9rmvQILwNiAHhOmcE= =osa8 -----END PGP SIGNATURE----- --=-=-=--