unofficial mirror of emacs-orgmode@gnu.org
 help / color / mirror / Atom feed
* org-in-org
@ 2021-02-23 14:24 Greg Minshall
  2021-02-23 19:46 ` org-in-org Berry, Charles via General discussions about Org-mode.
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Greg Minshall @ 2021-02-23 14:24 UTC (permalink / raw)
  To: emacs-orgmode

i have a question about org-in-org source blocks.  i volunteered to help
in an effort to provide a tutorial of using the ESS (Emacs Speaks
Statistics) package for R, in particular, from org mode.

i'd like to write my contribution as a .org file.  i'd like to include
fragments of org code, including source blocks (in R).  and, i'd like to
show various result types.  so, i'd like to be able to have the
#+RESULTS show up in the org-in-org source block as exported inside the
containing .org file.

and, i'd like to trigger all this from a makefile, using some emacs
batch script to export the containing .org file into a .html or .pdf
file.

(i *think*) what i would like to end up with is what it would like if i
had manually opened the org-in-org source blocks (C-c‌'), then went to
each (or, possibly, selected, i guess) source blocks inside *that*
(org-in-org) source block, and executed each, producing a #+RESULTS
block for each, then closed the org-in-org source block (C-c‌', again),
and then exported the containing .org file.

is this possible?  any ideas?

cheers, Greg


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

* Re: org-in-org
  2021-02-23 14:24 org-in-org Greg Minshall
@ 2021-02-23 19:46 ` Berry, Charles via General discussions about Org-mode.
  2021-02-23 20:30 ` org-in-org Erik Iverson
  2021-02-23 21:38 ` org-in-org Jeremie Juste
  2 siblings, 0 replies; 4+ messages in thread
From: Berry, Charles via General discussions about Org-mode. @ 2021-02-23 19:46 UTC (permalink / raw)
  To: Greg Minshall; +Cc: emacs-orgmode

Greg, 

See inline

> On Feb 23, 2021, at 6:24 AM, Greg Minshall <minshall@umich.edu> wrote:
> 
> i have a question about org-in-org source blocks.  i volunteered to help
> in an effort to provide a tutorial of using the ESS (Emacs Speaks
> Statistics) package for R, in particular, from org mode.
> 
> i'd like to write my contribution as a .org file.  i'd like to include
> fragments of org code, including source blocks (in R).  and, i'd like to
> show various result types.  so, i'd like to be able to have the
> #+RESULTS show up in the org-in-org source block as exported inside the
> containing .org file.

I think I get your intention. You want the visual to look like it would if the src-edit buffer was opened in emacs as org.

> 
> and, i'd like to trigger all this from a makefile, using some emacs
> batch script to export the containing .org file into a .html or .pdf
> file.
> 
> (i *think*) what i would like to end up with is what it would like if i
> had manually opened the org-in-org source blocks (C-c‌'), then went to
> each (or, possibly, selected, i guess) source blocks inside *that*
> (org-in-org) source block, and executed each, producing a #+RESULTS
> block for each, then closed the org-in-org source block (C-c‌', again),
> and then exported the containing .org file.
> 
> is this possible?  any ideas?


I have two alternative approaches:

1) Add an export engine for "org" to ox-ravel[1]. This is a trivial customization of `org-ravel-engines' to add a '("org" . "engine='org'") element.  Then add a custom language engine[2] for rmarkdown or knitr.

The actions for the makefile would be a ravel export to generate *.Rmd, *.Rnw, or *.Rhtml files followed by rmarkdown::render or knitr::knit on the generated files.

2) Define this function:

#+begin_src emacs-lisp
  (defun org-exe-org ()
    (let ((org-confirm-babel-evaluate nil))
      (org-edit-src-code)
      (org-babel-execute-buffer)
      (org-edit-src-exit)))
#+end_src

In an org buffer with one or more org src blocks containing R src blocks:

eval this

 (org-babel-map-executables nil (org-exe-org))

Then export the buffer to pdf or html.

I haven't tested this much, but for the snippet below evaluating that line and exporting to html produces two framed blocks with R src blocks and the results displayed in each:

--8<---------------cut here---------------start------------->8---
#+begin_src org
  ,#+begin_src R
    print("abc")
  ,#+end_src
#+end_src


#+begin_src org
  ,#+begin_src R
    print("def")
  ,#+end_src
#+end_src
--8<---------------cut here---------------end--------------->8---

I expect doing this in batch mode will not be a challenge.

For pdf output the result is rather plain. Maybe there is some minted idiom that would help?

HTH,
Chuck

p.s. I am an `ess-intro' member, in case it helps to move the conversation to there.


[1] https://github.com/chasberry/orgmode-accessories

[2] https://bookdown.org/yihui/rmarkdown-cookbook/custom-engine.html 

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

* Re: org-in-org
  2021-02-23 14:24 org-in-org Greg Minshall
  2021-02-23 19:46 ` org-in-org Berry, Charles via General discussions about Org-mode.
@ 2021-02-23 20:30 ` Erik Iverson
  2021-02-23 21:38 ` org-in-org Jeremie Juste
  2 siblings, 0 replies; 4+ messages in thread
From: Erik Iverson @ 2021-02-23 20:30 UTC (permalink / raw)
  To: Greg Minshall; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1492 bytes --]

Hi Greg!

I am not sure if this would be useful to your efforts, but I have an "R in
org-mode" tutorial on github:

https://github.com/erikriverson/org-mode-R-tutorial

Apparently it is now 10 years old somehow, time flies.

Best,
--Erik



On Tue, Feb 23, 2021 at 6:25 AM Greg Minshall <minshall@umich.edu> wrote:

> i have a question about org-in-org source blocks.  i volunteered to help
> in an effort to provide a tutorial of using the ESS (Emacs Speaks
> Statistics) package for R, in particular, from org mode.
>
> i'd like to write my contribution as a .org file.  i'd like to include
> fragments of org code, including source blocks (in R).  and, i'd like to
> show various result types.  so, i'd like to be able to have the
> #+RESULTS show up in the org-in-org source block as exported inside the
> containing .org file.
>
> and, i'd like to trigger all this from a makefile, using some emacs
> batch script to export the containing .org file into a .html or .pdf
> file.
>
> (i *think*) what i would like to end up with is what it would like if i
> had manually opened the org-in-org source blocks (C-c‌'), then went to
> each (or, possibly, selected, i guess) source blocks inside *that*
> (org-in-org) source block, and executed each, producing a #+RESULTS
> block for each, then closed the org-in-org source block (C-c‌', again),
> and then exported the containing .org file.
>
> is this possible?  any ideas?
>
> cheers, Greg
>
>

[-- Attachment #2: Type: text/html, Size: 2061 bytes --]

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

* Re: org-in-org
  2021-02-23 14:24 org-in-org Greg Minshall
  2021-02-23 19:46 ` org-in-org Berry, Charles via General discussions about Org-mode.
  2021-02-23 20:30 ` org-in-org Erik Iverson
@ 2021-02-23 21:38 ` Jeremie Juste
  2 siblings, 0 replies; 4+ messages in thread
From: Jeremie Juste @ 2021-02-23 21:38 UTC (permalink / raw)
  To: Greg Minshall; +Cc: emacs-orgmode

Hello Greg,

Many thanks for the effort. 
A possible solution might be this one 

#+NAME: readdata-code
#+BEGIN_SRC org
  ,#+NAME: readdata-code
  ,#+BEGIN_SRC R :results value silent

  read.data("datafile1.csv",sep=",",header=T)->mydata1


  ,#+END_SRC
#+END_SRC

credit goes to https://raw.githubusercontent.com/vikasrawal/orgpaper/master/orgpapers.org

Best regards,
Jeremie


On Tuesday, 23 Feb 2021 at 17:24, Greg Minshall wrote:
> i have a question about org-in-org source blocks.  i volunteered to help
> in an effort to provide a tutorial of using the ESS (Emacs Speaks
> Statistics) package for R, in particular, from org mode.
>
> i'd like to write my contribution as a .org file.  i'd like to include
> fragments of org code, including source blocks (in R).  and, i'd like to
> show various result types.  so, i'd like to be able to have the
> #+RESULTS show up in the org-in-org source block as exported inside the
> containing .org file.
>
> and, i'd like to trigger all this from a makefile, using some emacs
> batch script to export the containing .org file into a .html or .pdf
> file.
>
> (i *think*) what i would like to end up with is what it would like if i
> had manually opened the org-in-org source blocks (C-c‌'), then went to
> each (or, possibly, selected, i guess) source blocks inside *that*
> (org-in-org) source block, and executed each, producing a #+RESULTS
> block for each, then closed the org-in-org source block (C-c‌', again),
> and then exported the containing .org file.
>
> is this possible?  any ideas?
>
> cheers, Greg
>

-- 
Jeremie Juste


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

end of thread, other threads:[~2021-02-23 21:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-23 14:24 org-in-org Greg Minshall
2021-02-23 19:46 ` org-in-org Berry, Charles via General discussions about Org-mode.
2021-02-23 20:30 ` org-in-org Erik Iverson
2021-02-23 21:38 ` org-in-org Jeremie Juste

unofficial mirror of emacs-orgmode@gnu.org

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhetil.org/orgmode/0 orgmode/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 orgmode orgmode/ https://yhetil.org/orgmode \
		emacs-orgmode@gnu.org
	public-inbox-index orgmode

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.emacs.orgmode
	nntp://news.gmane.io/gmane.emacs.orgmode


AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git