Re: [O] [PATCH] Write org variables into own R environment instead of .GlobalEnv
Bastien writes: > Rainer M Krug writes: > >> OK - I'll let you know when I hear something. > > We should both hear about it. > > Please ping me if you don't hear anything in a month, > I'll then ask again to the FSF copyright clerk. I'll do - thanks. > > Also, the formatting of the Changelog entry is not correct, > please carefully read http://orgmode.org/worg/org-contribute.html OK - I will do so and re-send the patch. >>> >>> Thanks in advance! >> >> Patch is in a separate email - hope the commit message is better >> now. > > Looks good, thanks! Thanks, Rainer -- Rainer M. Krug email: Rainerkrugsde PGP: 0x0F52F982 pgpYuCv14UNjJ.pgp Description: PGP signature
Re: [O] [PATCH] Write org variables into own R environment instead of .GlobalEnv
Rainer M Krug writes: > OK - I'll let you know when I hear something. We should both hear about it. Please ping me if you don't hear anything in a month, I'll then ask again to the FSF copyright clerk. Also, the formatting of the Changelog entry is not correct, please carefully read http://orgmode.org/worg/org-contribute.html >>> >>> OK - I will do so and re-send the patch. >> >> Thanks in advance! > > Patch is in a separate email - hope the commit message is better > now. Looks good, thanks! -- Bastien
Re: [O] [PATCH] Write org variables into own R environment instead of .GlobalEnv
Bastien writes: > Hi Rainer, > > Rainer M Krug writes: > >> I mailed them on Tuesday, using the form >> [[http://orgmode.org/request-assign-future.txt]] but did not get a >> response. > > This usually take 4-6 weeks, so let's be patient. OK - I'll let you know when I hear something. > >>> Also, the formatting of the Changelog entry is not correct, >>> please carefully read http://orgmode.org/worg/org-contribute.html >> >> OK - I will do so and re-send the patch. > > Thanks in advance! Patch is in a separate email - hope the commit message is better now. Thanks, Rainer -- Rainer M. Krug email: Rainerkrugsde PGP: 0x0F52F982 pgpyFtFePcXIt.pgp Description: PGP signature
Re: [O] [PATCH] Write org variables into own R environment instead of .GlobalEnv
Hi Rainer, Rainer M Krug writes: > I mailed them on Tuesday, using the form > [[http://orgmode.org/request-assign-future.txt]] but did not get a > response. This usually take 4-6 weeks, so let's be patient. >> Also, the formatting of the Changelog entry is not correct, >> please carefully read http://orgmode.org/worg/org-contribute.html > > OK - I will do so and re-send the patch. Thanks in advance! -- Bastien
Re: [O] [PATCH] Write org variables into own R environment instead of .GlobalEnv
Bastien writes: > Hi Rainer, > > did you sign the FSF papers? We need this before considering applying > the patch. I mailed them on Tuesday, using the form [[http://orgmode.org/request-assign-future.txt]] but did not get a response. > Also, the formatting of the Changelog entry is not correct, > please carefully read http://orgmode.org/worg/org-contribute.html OK - I will do so and re-send the patch. Cheers, Rainer > > Thanks, -- Rainer M. Krug email: Rainerkrugsde PGP: 0x0F52F982 pgpXaE6hAVcvB.pgp Description: PGP signature
Re: [O] [PATCH] Write org variables into own R environment instead of .GlobalEnv
Hi Rainer, did you sign the FSF papers? We need this before considering applying the patch. Also, the formatting of the Changelog entry is not correct, please carefully read http://orgmode.org/worg/org-contribute.html Thanks, -- Bastien
[O] [PATCH] Write org variables into own R environment instead of .GlobalEnv
* (org-babel-R-assign-elisp): replaced simple assignments of variables to variables in R with assignments into an environment called 'org' and lock these so that they can not be modified anymore. * (org-babel-expand-body:R): wrap the call of `org-babel-variable-assignments:R' into - detachment of org environment - creation of new environment org to delete the old environment - locking of the org environment to prevent adding of bindings - appending of environment to search path of R These patch implements the writing of org variables into a separate R environment and attaches it to the search path. This solves several not so nice issues: 1) The org variables are now grouped and can be seen via 'ls(org)' in R 2) As the environment org and all bindings are locked, the variables can not be accidentally deleted. They can be overwritten, but they can be =restored by simply deleting the variable in R or by using `org$VARIABLE' instead of `VARIABLE' 3) All variables can be saved by simply calling `save(org, FILENAME' in R which makes it possible to store all variable definitions for tangling in one file. --- lisp/ob-R.el | 47 +++ 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/lisp/ob-R.el b/lisp/ob-R.el index 62aa7f2..da2aea2 100644 --- a/lisp/ob-R.el +++ b/lisp/ob-R.el @@ -103,8 +103,12 @@ this variable.") (append (when (cdr (assoc :prologue params)) (list (cdr (assoc :prologue params - (org-babel-variable-assignments:R params) - (list body) +'("try(detach(org), silent=TRUE)") + '("org <- new.env()") +(org-babel-variable-assignments:R params) +'("lockEnvironment(org)") +'("attach(org)") +(list body) (when (cdr (assoc :epilogue params)) (list (cdr (assoc :epilogue params))) (if graphics-file @@ -203,20 +207,31 @@ This function is called by `org-babel-execute-src-block'." "TRUE" "FALSE")) (row-names (if rownames-p "1" "NULL"))) (if (= max min) - (format "%s <- read.table(\"%s\", - header=%s, - row.names=%s, - sep=\"\\t\", - as.is=TRUE)" name file header row-names) - (format "%s <- read.table(\"%s\", - header=%s, - row.names=%s, - sep=\"\\t\", - as.is=TRUE, - fill=TRUE, - col.names = paste(\"V\", seq_len(%d), sep =\"\"))" - name file header row-names max -(format "%s <- %s" name (org-babel-R-quote-tsv-field value + (format "assign( + '%s', + read.table(\"%s\", + header=%s, + row.names=%s, + sep=\"\\t\", + as.is=TRUE + ), + envir = org + ) + lockBinding('%s', org)" name file header row-names name) + (format "assign( + '%s', + read.table(\"%s\", + header=%s, + row.names=%s, + sep=\"\\t\", + as.is=TRUE, + fill=TRUE, + col.names = paste(\"V\", seq_len(%d), sep =\"\") + ), + envir = org + ) + lockBinding('%s', org)" name file header row-names max name +(format "assign('%s', %s, envir = org); lockBinding('%s', org)" name (org-babel-R-quote-tsv-field value) name))) (defvar ess-ask-for-ess-directory) ; dynamically scoped (defun org-babel-R-initiate-session (session params) -- 1.8.5.2 (Apple Git-48) -- Rainer M. Krug email: RMKruggmailcom PGP: 0x0F52F982 pgp4BCq73wsCj.pgp Description: PGP signature