From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rainer M Krug Subject: Re: Folding in iESS R buffer Date: Tue, 27 May 2014 14:13:20 +0200 Message-ID: References: <87d2ez1vjq.fsf@gmail.com> <87tx8bzhe5.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]:46090) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WpGGG-0001Dr-88 for emacs-orgmode@gnu.org; Tue, 27 May 2014 08:13:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WpGGA-0002Ds-Ls for emacs-orgmode@gnu.org; Tue, 27 May 2014 08:13:44 -0400 Received: from mail-wg0-f51.google.com ([74.125.82.51]:33641) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WpGGA-0002DZ-Cj for emacs-orgmode@gnu.org; Tue, 27 May 2014 08:13:38 -0400 Received: by mail-wg0-f51.google.com with SMTP id x13so9407971wgg.22 for ; Tue, 27 May 2014 05:13:37 -0700 (PDT) In-Reply-To: <87tx8bzhe5.fsf@gmail.com> (Thorsten Jolitz's message of "Tue, 27 May 2014 11:43:14 +0200") 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: Thorsten Jolitz Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Thorsten Jolitz writes: > Rainer M Krug writes: > >> Rainer M Krug writes: >> >>> Thorsten Jolitz writes: >>> >>>> Rainer M Krug writes: >>>> >>>> Hi Rainer, >>>> >>>> sorry for the late reply, I was offline some time.=20 >>> >>> No problem. >>> >>>> >>>>> I have modified the variable transfer in ob-R.el so that the variable >>>>> transfer code is enclosed as can be seen below. >>>>> >>>>> My idea is that I can fold the R output so that the variable >>>>> transfer is >>>>> collapsed. I understand that I can use one of the org-outside-org min= or >>>>> modes [1] (presumibly utshine?) - but I can't figure out how. >>>>> >>>>> My questions are: >>>>> >>>>> 1) which enclosing should I use to fold the transfer code away? >>>> >>>> Outshine is like Org, no enclosing, but file structuring with >>>> (outcommented) headlines.=20 >>> >>> So everything after the outcommented headline will be folded - so if I >>> only want to fold one part, I have to use >>> >>> ,---- >>> | ## * If this is folded >>> | SOME R CODE >>> | ## * This not anymore >>> | SOME R CODE >>> `---- >>> >>> which I could fold to >>> >>> ,---- >>> | ## * If this is folded [...] >>> | ## * This not anymore >>> | SOME R CODE >>> `---- >>> >>> correct? >> >> I just tried it, and get the following: >> >> Unfolded: >> >> ,---- >> | >=20 >> | + . + ## * Variable Transfer from org >> | ########################################################## >> | ## org:variables environment created and in search path >> | ########################################################## >> |=20 >> | ## * Back to normal code >> | here it is @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ >> | > >=20 >> `---- >> >> where "here it is @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" is output >> From normal R code in a source block evaluated. >> >> Folded: >> >> ,---- >> | >=20 >> | + . + ## * Variable Transfer from org >> | ##########################################################... >> | here it is @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ >> | > >=20 >> `---- >> >> Is this what is expected? > > no, it should look just like a folded subtree in Org-mode.=20 > The problem is probably this > > ,-------------------------------------- > | + . + ## * Variable Transfer from org > `-------------------------------------- > > because in outshine, just like in Org, a header must (!) start at the > beginning of line to be recognized.=20 I changed it in the buffer, so that it now reads: ,---- | >=20 | ## * Variable Transfer from org | ########################################################## | ## org:variables environment created and in search path | ########################################################## |=20 | ## * Back to normal code | here it is @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | > >=20 `---- but the folding still results in ,---- | >=20 | ## * Variable Transfer from org | ##########################################################... | here it is @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | > >=20 `---- If it helps, here is the buffer: ,---- | R version 3.1.0 (2014-04-10) -- "Spring Dance" | Copyright (C) 2014 The R Foundation for Statistical Computing | Platform: x86_64-apple-darwin13.1.0 (64-bit) |=20 | R is free software and comes with ABSOLUTELY NO WARRANTY. | You are welcome to redistribute it under certain conditions. | Type 'license()' or 'licence()' for distribution details. |=20 | Natural language support but running in an English locale |=20 | R is a collaborative project with many contributors. | Type 'contributors()' for more information and | 'citation()' on how to cite R or R packages in publications. |=20 | Type 'demo()' for some demos, 'help()' for on-line help, or | 'help.start()' for an HTML browser interface to help. | Type 'q()' to quit R. |=20 | During startup - Warning messages: | 1: Setting LC_CTYPE failed, using "C"=20 | 2: Setting LC_COLLATE failed, using "C"=20 | 3: Setting LC_TIME failed, using "C"=20 | 4: Setting LC_MESSAGES failed, using "C"=20 | 5: Setting LC_MONETARY failed, using "C"=20 | > > options(STERM=3D'iESS', str.dendrogram.last=3D"'", editor=3D'emacscli= ent', show.error.locations=3DTRUE) | >=20 | ## * Variable Transfer from org | ########################################################## | ## org:variables environment created and in search path | ########################################################## |=20 | ## * Back to normal code | here it is @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | > >=20 `---- I figured it out: The problems are the comment lines - if I delete these, it is working. I can work around this. Cheers and thanks, Rainer > > Or is the comment syntax wrong for R-mode? Is it only > > ,------------- > | # * Level 1 > `------------- > > ? I can't check right now, you can try it out by writing an Org header in= an > R buffer and then call M-x comment-region on the marked line. Maybe I > got confused because PicoLisp uses ## for comments ... > >>>>> 2) which minor mode should I use for this and how can I configure it? >>>> >>>> I'm not sure if I understand. When you use ob-R.el, you work in Org >>>> files with R source blocks, right?=20 >>> >>> Correct. >>> >>>> When do you want to fold the R output below? When you are in org-mode >>>> or when editing source blocks in R-mode? >>> >>> The evaluated code - not in the source code. >>> >>>> >>>> In the former case, Org-mode is in charge and you don't need >>>> outshine.=20 >>> >>> True. >>> >>>> In the latter case, you could install outshine as described in the >>>> docs and then add outline-minor-mode to the ESS/R mode hook, i.e. >>> >>> That's it. >>> >>>> >>>> ,---------------------------------------------------------------------= ---------- >>>> | ;; outline >>>> | (when (require 'outline nil t) >>>> | (add-hook 'ess-mode-hook 'outline-minor-mode)) ; is that the >>>> | hook for R-mode? >>>> |=20 >>>> | ;; outshine >>>> | (when (require 'outshine nil t) >>>> | (add-hook 'outline-minor-mode-hook 'outshine-hook-function) >>>> | (setq outshine-use-speed-commands t)) >>>> `---------------------------------------------------------------------= ---------- >>>> >>>> Outshine headlines are outcommented Org headlines, i.e.=20 >>>> >>>> ,---------------------------------- >>>> | * Beginning org variable transfer >>>> `---------------------------------- >>>> >>>> becomes=20 >>>> >>>> ,---------- >>>> | ## * Beginning org variable transfer >>>> `---------- >>>> >>>> in R-mode.=20 >>>> >>>> The R output would become an outshine-subtree with the header above, >>>> just like in Org-mode, possibly surrounded by other subtrees. >>> >>> Sounds great - thanks a lot. I will try it out, >>> >>> Rainer >>> >>>> >>>>> --8<---------------cut here---------------start------------->8--- >>>>>> ####################################################################= ## >>>>> ## Beginning org variable transfer >>>>> try(detach(.org_variables_), silent=3DTRUE) >>>>> .org_variables_ <- new.env() >>>>> assign( 'COLUMNS', read.table("/var/folders/50/wcr5bjwn75q595n6x8= 2gxj280000gn/T/babel-74428N93/R-import-74428U4A", header=3DTRUE, row.names= =3D1, sep=3D"\t", as.is=3DTRUE ), envir =3D .org_variables_ ); lockBinding(= 'COLUMNS', .org_variables_) >>>>> assign( 'COLS_TO_EVAL', read.table("/var/folders/50/wcr5bjwn75q59= 5n6x82gxj280000gn/T/babel-74428N93/R-import-74428hCH", header=3DTRUE, row.n= ames=3D1, sep=3D"\t", as.is=3DTRUE ), envir =3D .org_variables_ ); lockBind= ing('COLS_TO_EVAL', .org_variables_) >>>>> assign( 'ALLSPECIES', read.table("/var/folders/50/wcr5bjwn75q595n= 6x82gxj280000gn/T/babel-74428N93/R-import-74428uMN", header=3DTRUE, row.nam= es=3D1, sep=3D"\t", as.is=3DTRUE ), envir =3D .org_variables_ ); lockBindin= g('ALLSPECIES', .org_variables_) >>>>> assign( 'SPECIES', read.table("/var/folders/50/wcr5bjwn75q595n6x8= 2gxj280000gn/T/babel-74428N93/R-import-744287WT", header=3DTRUE, row.names= =3D1, sep=3D"\t", as.is=3DTRUE ), envir =3D .org_variables_ ); lockBinding(= 'SPECIES', .org_variables_) >>>>> assign( 'YEARS', read.table("/var/folders/50/wcr5bjwn75q595n6x82g= xj280000gn/T/babel-74428N93/R-import-74428IhZ", header=3DTRUE, row.names=3D= 1, sep=3D"\t", as.is=3DTRUE ), envir =3D .org_variables_ ); lockBinding('YE= ARS', .org_variables_) >>>>> assign('PRESENT', 2008, envir =3D .org_variables_); lockBinding('= PRESENT', .org_variables_) >>>>> assign('MINEFFORT', 3, envir =3D .org_variables_); lockBinding('M= INEFFORT', .org_variables_) >>>>> assign('PROPTRAIN', 0.6, envir =3D .org_variables_); lockBinding(= 'PROPTRAIN', .org_variables_) >>>>> assign('RNGSEED', 13, envir =3D .org_variables_); lockBinding('RN= GSEED', .org_variables_) >>>>> assign('RNGKIND', "Mersenne-Twister", envir =3D .org_variables_);= lockBinding('RNGKIND', .org_variables_) >>>>> assign('RNGNORMALKIND', "Inversion", envir =3D .org_variables_); = lockBinding('RNGNORMALKIND', .org_variables_) >>>>> assign('REFGRID', "./refGrid_8km.rds", envir =3D .org_variables_)= ; lockBinding('REFGRID', .org_variables_) >>>>> assign('IFN', "./__BOX__/IFN/DB_IFN/rds/tabplot.rds", envir =3D .= org_variables_); lockBinding('IFN', .org_variables_) >>>>> assign('IFNCOUNT', "./__BOX__/IFN/DB_IFN/rdsRasterized/tabplot.co= unt.8km.rds", envir =3D .org_variables_); lockBinding('IFNCOUNT', .org_vari= ables_) >>>>> assign('IFNMEAN', "./__BOX__/IFN/DB_IFN/rdsRasterized/tabplot.mea= n.8km.rds", envir =3D .org_variables_); lockBinding('IFNMEAN', .org_variabl= es_) >>>>> assign('IFNPRES', "./__BOX__/IFN/DB_IFN/rdsRasterized/tabplot.pre= s.8km.rds", envir =3D .org_variables_); lockBinding('IFNPRES', .org_variabl= es_) >>>>> assign('IFNSD', "./__BOX__/IFN/DB_IFN/rdsRasterized/tabplot.sd.8k= m.rds", envir =3D .org_variables_); lockBinding('IFNSD', .org_variables_) >>>>> assign('IFNTABTREE', "./__BOX__/IFN/DB_IFN/rds/tabtree.rds", envi= r =3D .org_variables_); lockBinding('IFNTABTREE', .org_variables_) >>>>> lockEnvironment(.org_variables_) >>>>> attach(.org_variables_) >>>>> save(.org_variables_, file=3D'org_variables.RData') >>>>> ## end org variable transfer >>>>> ###################################################################### >>>>> --8<---------------cut here---------------end--------------->8--- >>>>> >>>>> >>>>> Footnotes:=20 >>>>> [1] http://orgmode.org/worg/org-tutorials/org-outside-org.html =2D-=20 Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology,= UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Stellenbosch University South Africa Tel : +33 - (0)9 53 10 27 44 Cell: +33 - (0)6 85 62 59 98 Fax : +33 - (0)9 58 10 27 44 Fax (D): +49 - (0)3 21 21 25 22 44 email: Rainer@krugs.de Skype: RMkrug PGP: 0x0F52F982 --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.22 (Darwin) iQEcBAEBAgAGBQJThIFsAAoJENvXNx4PUvmCruUIAJIXWd8zYAt9mwVulZGoVfMu 85MKYfuu3HE5LVbnM0RLWXua1KzsRxugr+9LQMEDg9fARC3s4kRCmpxUBp34R7fd c6v5uN7+GQsIHiWhckX2rXeOSb35nWEYNo9a9Cfd9wUyTgNfbkSO2F8i8vEu6vP3 9TVmK63O+0/kX8bdbGMc/iyaonYtyWa9+NIOnTY1VCsJMq+vTe+eSyKfngf3qnT9 +4GDVK9NSGr603IqmtIIHCRnJeLNMM6/QIGaAWTf64p4EgzWPhH/Qv99fBmCDVsR QXbqu/udB7njEtYqVhFVxuERQ71slw9cVs3VWRIlpmE1TzidgQsJqMyYjq0Z88M= =TPRq -----END PGP SIGNATURE----- --=-=-=--