emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Org babel R command session
@ 2024-07-02 10:46 Sam
  2024-07-02 14:35 ` Ihor Radchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Sam @ 2024-07-02 10:46 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org (emacs-orgmode@gnu.org)

I just noticed an inconsistency between the way ob-R and ob-python
select executables. For python, there are 3 variables:
org-babel-python-command, org-babel-python-command-session and
org-babel-python-command-nonsession, with the former overriding the
latter two.
 
For R, there is only org-babel-R-command, which is ignored when running
as a session.
 
Is it worth trying to make the R functionality as similar as possible to
the python? If so then I'm happy to submit a patch doing just
that. However, I'm not sure what is the best way to handle giving
command-line arguments to the R interpreter when initialising a session,
because you need to set inferior-ess-program to the executable
specifically, and put any arguments in inferior-R-args.
 
Cheers,
Sam


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Org babel R command session
  2024-07-02 10:46 Org babel R command session Sam
@ 2024-07-02 14:35 ` Ihor Radchenko
  2024-07-02 14:58   ` Sam Crawford
  0 siblings, 1 reply; 5+ messages in thread
From: Ihor Radchenko @ 2024-07-02 14:35 UTC (permalink / raw)
  To: Sam; +Cc: emacs-orgmode@gnu.org (emacs-orgmode@gnu.org)

Sam <sam@crawf.uk> writes:

> I just noticed an inconsistency between the way ob-R and ob-python
> select executables. For python, there are 3 variables:
> org-babel-python-command, org-babel-python-command-session and
> org-babel-python-command-nonsession, with the former overriding the
> latter two.

This was added because it is relatively common to use different commands
for session and non-session python blocks (things like ipython
vs. python).
  
> For R, there is only org-babel-R-command, which is ignored when running
> as a session.
> 
> Is it worth trying to make the R functionality as similar as possible to
> the python? If so then I'm happy to submit a patch doing just
> that. However, I'm not sure what is the best way to handle giving
> command-line arguments to the R interpreter when initialising a session,
> because you need to set inferior-ess-program to the executable
> specifically, and put any arguments in inferior-R-args.

The question is whether it is practically useful to have separate
commands for R session and R non-session blocks. For most interpreters,
it is not very useful - they use the same command.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Org babel R command session
  2024-07-02 14:35 ` Ihor Radchenko
@ 2024-07-02 14:58   ` Sam Crawford
  2024-07-02 15:11     ` Ihor Radchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Sam Crawford @ 2024-07-02 14:58 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode@gnu.org (emacs-orgmode@gnu.org)



On 02/07/2024 15:35, Ihor Radchenko wrote:
> Sam <sam@crawf.uk> writes:
> 
>> I just noticed an inconsistency between the way ob-R and ob-python
>> select executables. For python, there are 3 variables:
>> org-babel-python-command, org-babel-python-command-session and
>> org-babel-python-command-nonsession, with the former overriding the
>> latter two.
> 
> This was added because it is relatively common to use different commands
> for session and non-session python blocks (things like ipython
> vs. python).
>    
>> For R, there is only org-babel-R-command, which is ignored when running
>> as a session.
>>
>> Is it worth trying to make the R functionality as similar as possible to
>> the python? If so then I'm happy to submit a patch doing just
>> that. However, I'm not sure what is the best way to handle giving
>> command-line arguments to the R interpreter when initialising a session,
>> because you need to set inferior-ess-program to the executable
>> specifically, and put any arguments in inferior-R-args.
> 
> The question is whether it is practically useful to have separate
> commands for R session and R non-session blocks. For most interpreters,
> it is not very useful - they use the same command.
> 

I agree that it's unlikely that users will want separate commands
(though tools like radian do exist).

Regardless, there is still the issue that, if :session is not none, then
babel will ignore org-babel-R-command, as it just makes a call to
run-ess-R. So even if you don't want to add more variables (which
ultimately I'd agree with), it might still be worth wrapping that call
in something like

(let ((inferior-ess-R-program (or org-babel-R-command
                                   inferior-ess-R-program)))
      ...)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Org babel R command session
  2024-07-02 14:58   ` Sam Crawford
@ 2024-07-02 15:11     ` Ihor Radchenko
  2024-07-12 10:05       ` Ihor Radchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Ihor Radchenko @ 2024-07-02 15:11 UTC (permalink / raw)
  To: Sam Crawford; +Cc: emacs-orgmode@gnu.org (emacs-orgmode@gnu.org)

Sam Crawford <sam@crawf.uk> writes:

>> The question is whether it is practically useful to have separate
>> commands for R session and R non-session blocks. For most interpreters,
>> it is not very useful - they use the same command.
>> 
>
> I agree that it's unlikely that users will want separate commands
> (though tools like radian do exist).
>
> Regardless, there is still the issue that, if :session is not none, then
> babel will ignore org-babel-R-command, as it just makes a call to
> run-ess-R. So even if you don't want to add more variables (which
> ultimately I'd agree with), it might still be worth wrapping that call
> in something like
>
> (let ((inferior-ess-R-program (or org-babel-R-command
>                                    inferior-ess-R-program)))
>       ...)

Or we can just document that ESS defaults are used for sessions and ask
users to customize inferior-ess-R-program if they need something
non-standard for sessions.

The problem with `inferior-ess-R-program' is that it must be executable
name, and cannot be command with arguments, as in our default value of
org-babel-R-command: "R --slave --no-save". In the absense of people who
are actually making use of the proposed feature, I see no reasons to
complicate the code.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Org babel R command session
  2024-07-02 15:11     ` Ihor Radchenko
@ 2024-07-12 10:05       ` Ihor Radchenko
  0 siblings, 0 replies; 5+ messages in thread
From: Ihor Radchenko @ 2024-07-12 10:05 UTC (permalink / raw)
  To: Sam Crawford; +Cc: emacs-orgmode@gnu.org (emacs-orgmode@gnu.org)

Ihor Radchenko <yantar92@posteo.net> writes:

> Or we can just document that ESS defaults are used for sessions and ask
> users to customize inferior-ess-R-program if they need something
> non-standard for sessions.
>
> The problem with `inferior-ess-R-program' is that it must be executable
> name, and cannot be command with arguments, as in our default value of
> org-babel-R-command: "R --slave --no-save". In the absense of people who
> are actually making use of the proposed feature, I see no reasons to
> complicate the code.

Fixed, on the ob-R documentation page in WORG.
https://git.sr.ht/~bzg/worg/commit/c6380ced

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-07-12 10:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-02 10:46 Org babel R command session Sam
2024-07-02 14:35 ` Ihor Radchenko
2024-07-02 14:58   ` Sam Crawford
2024-07-02 15:11     ` Ihor Radchenko
2024-07-12 10:05       ` Ihor Radchenko

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).