emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Charles C. Berry" <ccberry@ucsd.edu>
To: Rainer M Krug <Rainer@krugs.de>
Cc: Bastien <bzg@gnu.org>,
	"emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>,
	Eric Schulte <schulte.eric@gmail.com>
Subject: Re: [babel][PATCHES] ob-R patches for review
Date: Mon, 12 May 2014 15:05:11 -0700	[thread overview]
Message-ID: <alpine.OSX.2.00.1405121405050.6955@charles-berrys-macbook.local> (raw)
In-Reply-To: <m2a9amu86j.fsf@krugs.de>

On Mon, 12 May 2014, Rainer M Krug wrote:

> Eric Schulte <schulte.eric@gmail.com> writes:
>
>>>> If not would you mind submitting a version of the patches split into
>>>> multiple commits with as much of the hard-coded R code as feasible
>>>> placed into customizable variables along the lines of the
>>>> `org-babel-R-assign-elisp-function' variable suggested by Charles.
>>>
>>> I am thinking of actually not providing the R code in org-variables, but
>>> to put them into R files and to source them. By doing this, the
>>> customization could be done in R, which will be much easier for R users
>>> then to customize emacs variables.
>>>
>>
>> I think this is a bad idea, such external R source files may be hard to
>> manage and load reliably across systems
>
> I see your points, but I am looking at ESS (which is loading .R files as
> well into the ESSR environment) and whose loading mechanism I want
> to piggy back the loading of .R for org. If I understand the variable
> transfer from org to R correctly, it anyway only works on local R
> sessions, which makes it even easier to do then ESS which also caters
> for remote R sessions.
> My idea is to have all R code in one directory and to let ESS load it
> upon initialization of ESS (which is a dependency of running R from org
> anyway, if I am not mistaken).

Not quite. You can run R src blocks without (require 'ess) if they require 
no session. (I do not claim that anyone actually runs R src blocks who 
lacks a working ESS installation, just saying...)


> I have a prototype working, and will keep
> you posted. The complication would be that a newer version of ESS would
> be needed.
>

Maybe load the ESS and R files if

   (and (fboundp 'ess-version)
        (not (string<
              (ess-version)
              "ess-version: <least-version>")))

and fallback to the existing version of ob-R.el (or something like it) 
otherwise.

> The other option would be to just copy the code ESS uses into org, which
> would make the process independent of changes in ESS. But I don't like
> the duplication of code.
>
>> and it is not clear where they should live in the Org-mode repository.
>
> I would suggest in a etc/R.
>

IIUC, someone on ESS core will support your effort. So maybe you can have 
an etc/ESSR/R/org-mode.R file.

Since you will have a mix of elisp and R, it might make sense to have 
minimal callouts on the org-mode side to an elisp wrapper on the ESS side. 
Then you can maintain the trickier elisp on the ESS side, so changes in 
elisp that require changes in R or vice versa can be made in unison.

>> Additionally, if the variables simply hold R code text, then users can
>> easily initialize them from R files locally with something like the
>> following.
>>
>>     (setq org-babel-R-assign-elisp-function
>>           (with-temp-buffer
>>             (insert-file-contents-literally "personal.R")
>>             (buffer-string)))
>>
>> I think this approach is much simpler.
>
> True - but I like the simplicity of being able to customize the
> behavior of org-babel-R by writing an R function without having to thin
> about elisp. But maybe there is a way of doing both...
>

noweb will do it. Quote the chunk like this:

#+BEGIN_SRC emacs-lisp :noweb yes :tangle elisp-R.el
   (setq rlines "
<<r-code>>")
#+END_SRC


HTH,

Chuck


Charles C. Berry                            Dept of Family/Preventive Medicine
cberry at ucsd edu			    UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, CA 92093-0901

  reply	other threads:[~2014-05-12 22:11 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-29 12:43 [babel][PATCHES] ob-R patches for review Rainer M Krug
2014-04-29 18:15 ` Charles Berry
2014-04-30 12:28   ` Rainer M Krug
2014-04-30 22:49     ` Charles C. Berry
2014-05-01  9:10       ` Rainer M Krug
2014-05-07 10:27 ` Eric Schulte
2014-05-08  2:26   ` Charles Berry
2014-05-08 10:02     ` Rainer M Krug
2014-05-09  9:11       ` Rainer M Krug
2014-05-09 12:02         ` Rainer M Krug
2014-05-08  9:57   ` Rainer M Krug
2014-05-09 13:03     ` Bastien
2014-05-09 13:45       ` Rainer M Krug
2014-05-09 14:34         ` Eric Schulte
2014-05-12  8:33           ` Rainer M Krug
2014-05-12 12:23             ` Suvayu Ali
2014-05-12 12:41               ` Rainer M Krug
2014-05-12 14:01             ` Queestion concerning lists - was: " Rainer M Krug
2014-05-12 15:23               ` Eric Schulte
2014-05-12 15:21             ` Eric Schulte
2014-05-12 19:08               ` Rainer M Krug
2014-05-12 22:05                 ` Charles C. Berry [this message]
     [not found]                   ` <m2y4y2f499.fsf@krugs.de>
2014-05-16 18:22                     ` Charles C. Berry
2014-06-06 16:11                 ` 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=alpine.OSX.2.00.1405121405050.6955@charles-berrys-macbook.local \
    --to=ccberry@ucsd.edu \
    --cc=Rainer@krugs.de \
    --cc=bzg@gnu.org \
    --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).