* tangling from multiple files
@ 2020-03-17 23:21 David Bremner
2020-03-18 22:10 ` Berry, Charles via General discussions about Org-mode.
0 siblings, 1 reply; 8+ messages in thread
From: David Bremner @ 2020-03-17 23:21 UTC (permalink / raw
To: emacs-orgmode
I've seen this question around e.g. stack overflow, but none of the
answers I found seems really satisfactory.
I'd like to share a set of begin_src / end_src blocks in a.org between
b.org and c.org; in particular b.org and c.org contain noweb references
to names defined in a.org. Is there a better way than using
(org-babel-lob-ingest "a.org")? This seems a bit clunky, requiring
manual action every time a.org changes.
For example, here is a.org
#+name: x.scm
#+begin_src scheme
(define x 1)
#+end_src
#+name: y.scm
#+begin_src scheme
(define y 2)
#+end_src
and here is b.org. You can imagine c is similar, but maybe swaps the
order of x and y
#+begin_src scheme :tangle "b.scm" :noweb strip-export
<<x.scm>>
<<y.scm>>
#+end_src
# Local Variables:
# eval: (org-babel-lob-ingest "a.org")
# End:
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: tangling from multiple files
2020-03-17 23:21 tangling from multiple files David Bremner
@ 2020-03-18 22:10 ` Berry, Charles via General discussions about Org-mode.
2020-03-19 1:29 ` David Bremner
0 siblings, 1 reply; 8+ messages in thread
From: Berry, Charles via General discussions about Org-mode. @ 2020-03-18 22:10 UTC (permalink / raw
To: David Bremner; +Cc: emacs-orgmode@gnu.org
> On Mar 17, 2020, at 4:21 PM, David Bremner <david@tethera.net> wrote:
>
>
> I've seen this question around e.g. stack overflow, but none of the
> answers I found seems really satisfactory.
>
> I'd like to share a set of begin_src / end_src blocks in a.org between
> b.org and c.org; in particular b.org and c.org contain noweb references
> to names defined in a.org. Is there a better way than using
> (org-babel-lob-ingest "a.org")? This seems a bit clunky, requiring
> manual action every time a.org changes.
>
Put
#+include: ./a./org
directives in b.org and c.org
You might want to put the directives inside a non-exported drawer. See `org-export-with-drawers’ docstring.
HTH,
Chuck
> For example, here is a.org
>
> #+name: x.scm
> #+begin_src scheme
> (define x 1)
> #+end_src
>
> #+name: y.scm
> #+begin_src scheme
> (define y 2)
> #+end_src
>
> and here is b.org. You can imagine c is similar, but maybe swaps the
> order of x and y
>
> #+begin_src scheme :tangle "b.scm" :noweb strip-export
> <<x.scm>>
> <<y.scm>>
> #+end_src
>
> # Local Variables:
> # eval: (org-babel-lob-ingest "a.org")
> # End:
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: tangling from multiple files
2020-03-18 22:10 ` Berry, Charles via General discussions about Org-mode.
@ 2020-03-19 1:29 ` David Bremner
2020-03-19 2:38 ` Berry, Charles via General discussions about Org-mode.
0 siblings, 1 reply; 8+ messages in thread
From: David Bremner @ 2020-03-19 1:29 UTC (permalink / raw
To: Berry, Charles; +Cc: emacs-orgmode@gnu.org
"Berry, Charles" <ccberry@health.ucsd.edu> writes:
>> On Mar 17, 2020, at 4:21 PM, David Bremner <david@tethera.net> wrote:
>>
>>
>> I've seen this question around e.g. stack overflow, but none of the
>> answers I found seems really satisfactory.
>>
>> I'd like to share a set of begin_src / end_src blocks in a.org between
>> b.org and c.org; in particular b.org and c.org contain noweb references
>> to names defined in a.org. Is there a better way than using
>> (org-babel-lob-ingest "a.org")? This seems a bit clunky, requiring
>> manual action every time a.org changes.
>>
>
>
> Put
>
> #+include: ./a./org
>
> directives in b.org and c.org
>
> You might want to put the directives inside a non-exported drawer. See `org-export-with-drawers’ docstring.
This works fine (modulo the extra /) for exporting, but doesn't seem to
work for tangling. Does it work for tangling for you; i.e. is b.scm
produced with the two defines in it?
d
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: tangling from multiple files
2020-03-19 1:29 ` David Bremner
@ 2020-03-19 2:38 ` Berry, Charles via General discussions about Org-mode.
2020-03-19 17:40 ` Berry, Charles via General discussions about Org-mode.
0 siblings, 1 reply; 8+ messages in thread
From: Berry, Charles via General discussions about Org-mode. @ 2020-03-19 2:38 UTC (permalink / raw
To: David Bremner; +Cc: emacs-orgmode@gnu.org
> On Mar 18, 2020, at 6:29 PM, David Bremner <david@tethera.net> wrote:
>
> "Berry, Charles" <ccberry@health.ucsd.edu> writes:
>
>>> On Mar 17, 2020, at 4:21 PM, David Bremner <david@tethera.net> wrote:
>>>
>>>
>>> I've seen this question around e.g. stack overflow, but none of the
>>> answers I found seems really satisfactory.
>>>
>>> I'd like to share a set of begin_src / end_src blocks in a.org between
>>> b.org and c.org; in particular b.org and c.org contain noweb references
>>> to names defined in a.org. Is there a better way than using
>>> (org-babel-lob-ingest "a.org")? This seems a bit clunky, requiring
>>> manual action every time a.org changes.
>>>
>>
>>
>> Put
>>
>> #+include: ./a./org
>>
>> directives in b.org and c.org
>>
>> You might want to put the directives inside a non-exported drawer. See `org-export-with-drawers’ docstring.
>
> This works fine (modulo the extra /) for exporting, but doesn't seem to
> work for tangling. Does it work for tangling for you; i.e. is b.scm
> produced with the two defines in it?
>
Right. It does not work directly for tangling. So also use
#+export_file_name: b2.org
(say)
Then load ox-ob.el, export as C-c C-e O o (org-org-export-to-org), visit b2.org and tangle from there.
HTH,
Chuck
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: tangling from multiple files
2020-03-19 2:38 ` Berry, Charles via General discussions about Org-mode.
@ 2020-03-19 17:40 ` Berry, Charles via General discussions about Org-mode.
2020-04-04 18:08 ` David Bremner
0 siblings, 1 reply; 8+ messages in thread
From: Berry, Charles via General discussions about Org-mode. @ 2020-03-19 17:40 UTC (permalink / raw
To: David Bremner; +Cc: emacs-orgmode@gnu.org
Oops. Correction below.
> On Mar 18, 2020, at 7:38 PM, Berry, Charles <ccberry@health.ucsd.edu> wrote:
>
>
> Right. It does not work directly for tangling. So also use
>
> #+export_file_name: b2.org
>
> (say)
>
> Then load ox-ob.el,
load ox-org.el, rather.
> export as C-c C-e O o (org-org-export-to-org), visit b2.org and tangle from there.
>
> HTH,
>
> Chuck
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: tangling from multiple files
2020-03-19 17:40 ` Berry, Charles via General discussions about Org-mode.
@ 2020-04-04 18:08 ` David Bremner
2020-04-05 17:56 ` Berry, Charles via General discussions about Org-mode.
0 siblings, 1 reply; 8+ messages in thread
From: David Bremner @ 2020-04-04 18:08 UTC (permalink / raw
To: Berry, Charles; +Cc: emacs-orgmode@gnu.org
"Berry, Charles" <ccberry@health.ucsd.edu> writes:
> Oops. Correction below.
>
>> On Mar 18, 2020, at 7:38 PM, Berry, Charles <ccberry@health.ucsd.edu> wrote:
>>
>>
>> Right. It does not work directly for tangling. So also use
>>
>> #+export_file_name: b2.org
>>
>> (say)
>>
>> Then load ox-ob.el,
>
> load ox-org.el, rather.
>
>> export as C-c C-e O o (org-org-export-to-org), visit b2.org and tangle from there.
I finally got around to trying this. In a broad sense it works, but
(at least with default settings) it loses the keywords on individual
source blocks.
if a.org looks like
#+include: c.org
#+export_file_name: foo.org
#+begin_src python :tangle foo.py :noweb true
<<test.py>>
def hello():
test()
#+end_src
then foo.org looks like
# Created 2020-04-04 Sat 15:03
#+TITLE:
#+AUTHOR: David Bremner
#+name test.py
#+begin_src python
def test:
print("test")
#+end_src
#+export_file_name: foo.org
#+begin_src python
<<test.py>>
def hello():
test()
#+end_src
Since my org files all tangle to multiple source files, this doesn't
really work for me. I guess I could have a single wrapper file for each
file I want to tangle to, but I have other keywords e.g. :shebang, whose
loss will still break things.
d
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: tangling from multiple files
2020-04-04 18:08 ` David Bremner
@ 2020-04-05 17:56 ` Berry, Charles via General discussions about Org-mode.
2020-04-08 17:14 ` David Bremner
0 siblings, 1 reply; 8+ messages in thread
From: Berry, Charles via General discussions about Org-mode. @ 2020-04-05 17:56 UTC (permalink / raw
To: David Bremner; +Cc: emacs-orgmode@gnu.org
> On Apr 4, 2020, at 11:08 AM, David Bremner <david@tethera.net> wrote:
>
> "Berry, Charles" <ccberry@health.ucsd.edu> writes:
>
>> Oops. Correction below.
>>
>>> On Mar 18, 2020, at 7:38 PM, Berry, Charles <ccberry@health.ucsd.edu> wrote:
>>>
>>>
>>> Right. It does not work directly for tangling. So also use
>>>
>>> #+export_file_name: b2.org
>>>
>>> (say)
>>>
>>> Then load ox-ob.el,
>>
>> load ox-org.el, rather.
>>
>>> export as C-c C-e O o (org-org-export-to-org), visit b2.org and tangle from there.
>
> I finally got around to trying this. In a broad sense it works, but
> (at least with default settings) it loses the keywords on individual
> source blocks.
I see.
It looks like you are back to `org-babel-lob-ingest'.
Maybe the issue you raised at the start of having to re-ingest after changes could be addressed by a function in `org-babel-pre-tangle-hook'.
HTH,
Chuck
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: tangling from multiple files
2020-04-05 17:56 ` Berry, Charles via General discussions about Org-mode.
@ 2020-04-08 17:14 ` David Bremner
0 siblings, 0 replies; 8+ messages in thread
From: David Bremner @ 2020-04-08 17:14 UTC (permalink / raw
To: Berry, Charles; +Cc: emacs-orgmode@gnu.org
"Berry, Charles" <ccberry@health.ucsd.edu> writes:
> I see.
>
> It looks like you are back to `org-babel-lob-ingest'.
>
> Maybe the issue you raised at the start of having to re-ingest after changes could be addressed by a function in `org-babel-pre-tangle-hook'.
Thanks for the suggestion. I wrote up my solution at
http://www.cs.unb.ca/~bremner/blog/posts/tangle-multi/
It doesn't really seem robust enough to be included in org-mode (even if
rewritten to remove the use of a hook), but it gets the job done for me.
d
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2020-04-08 17:14 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-17 23:21 tangling from multiple files David Bremner
2020-03-18 22:10 ` Berry, Charles via General discussions about Org-mode.
2020-03-19 1:29 ` David Bremner
2020-03-19 2:38 ` Berry, Charles via General discussions about Org-mode.
2020-03-19 17:40 ` Berry, Charles via General discussions about Org-mode.
2020-04-04 18:08 ` David Bremner
2020-04-05 17:56 ` Berry, Charles via General discussions about Org-mode.
2020-04-08 17:14 ` David Bremner
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.