1

My team is using a big single org-mode file to manage our research notes but some people are complaining that the file is getting too big too manage and the git conflicts are becoming a pain.

The docs say to use links to manage multiple .org files, like a wiki, but that also suffers from the git conflict problem (now when two people add a file, their link suffers the conflict) plus it's a massive pain to maintain the links.

Is there a way to automatically include a subfolder of .org files in a main file, or (as a fallback) automatically generate the table of files to include? Order is not important but I suppose lexicographic ordering of the filenames would be useful.

Ideally, I'd like to be able to compile out the entire document to one readable HTML page so links out to separate documents is very much sub-optimal.

  • In which order should the files be included? An automated solution won't let you have control over that. Are you really going from a one file situation to a hundreds of files situation at once? – YoungFrog Apr 20 '17 at 10:34
  • 1
    Org Babel blocks can output Org code. So you can use an ls or find or dir command to generate #+INCLUDE statements for a folder hierarchy. – mankoff Apr 20 '17 at 11:11
  • oooh that sounds interesting @mankoff could you please expand on that? – fommil Apr 20 '17 at 13:55
2

Babel can generate Org code. Try evaluating a Babel block on export that generates the +#INCLUDE: statements for you.

#+BEGIN_SRC sh :results raw drawer
for f in $(find /path/to/files/ -name "*.org"); do
    echo "#+INCLUDE: " $f
done
#+END_SRC

Generates:

#+RESULTS:
:RESULTS:
#+INCLUDE:  /path/to/files/A.org
#+INCLUDE:  /path/to/files/Bsubdir/foo.org
#+INCLUDE:  /path/to/files/C.org
:END:
  • oh wow, simple and powerful, I like it! Just need to rerun this every couple of weeks to ensure everything is in sync. – fommil Apr 20 '17 at 15:19
  • 2
    Using :results drawer replace, the export engine will handle the INCLUDE keywords appropriately. – mutbuerger Apr 20 '17 at 16:08
1

It seems like including other files could be what you want. It is a way to include other files in an org-file (could be other org-files or other file types), but when exporting it will all be exported as a single document.

  • cool, but it doesn't include folders of org files, right? Let's say I have 100 files across two folders and I don't want to have to manually manage that. – fommil Apr 20 '17 at 10:24
  • 1
    No, I do not think it works on folders. In what order would those 100 files appear in the document, in that case? Perhaps the publishing functionality could be used for this case: orgmode.org/manual/Publishing.html – Erik Sjöstrand Apr 20 '17 at 11:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.