0

How do I include the contents of a .edn file as a subset of another .edn file similar to the "include path" element in XML?

More specifically, does the extensable data notation (EDN) have a way to "include" a file via path similar to the "include path" element in XML.

I had a rather large keybinding project in XML format that was made much more navigable and less unwieldy by separating each section into files that could be easily jumped to and manipulated from a parent file made up "include path" elements. This allowed discrete section of my code to be toggled off/on by commenting one line and let me alter the sequence by just bubbling a line up or down. The project has since migrated from XML to EDN format I and I'm getting frustrated working with one enormous .edn file. I've put a lot of time into indentation, code folding, bookmarks... but it's like trying to read a book printed on one long scroll of parchment.

I should mention the .edn file is used by a program (Goku) to generate an even more enormous and unwieldy JSON file. don't know if that has any implications on the best solution. Thanks.

Old XML "parent" file with "include path" elements

New enormous EDN file with sections attempted to be broken up with indentation, code folding, colored comments, bookmarks and formatting

I've looked up "including files in EDN format" but maybe this is really a Clojure question. I'm not really an experienced programmer so not sure if I should really be looking through Clojure documentation as, from what I understand, edn is a subset of the Clojure language

see images for code https://i.stack.imgur.com/TBUVF.jpg

Ideally, I would like to have one master parent file consisting of "includes" my many smaller files for easier navigation.

akond
  • 15,865
  • 4
  • 35
  • 55
loudog
  • 1
  • 1

2 Answers2

3

XML doesn't include anything. It is just data. Inclusion happens within XML processors, such as XSL, when they are run.

This is precisely so for EDN. If you want an inclusion, you just say something along the lines of [:include "this file also"], and then walk over the data structure and substitute all includes with real data.

akond
  • 15,865
  • 4
  • 35
  • 55
  • So the element function of consolidating resources in separate file location was specific to the software the xml was configuring? (in this case keybinding software called [Karabiner](https://pqrs.org/osx/karabiner/))
    So what would the equivalent look my EDN file? the path I want to include is ~/Dropbox/Sync/KarabinerElements/karabinerSync.edn Is this how you're saying it works? https://imgur.com/a/TCc4HL2
    – loudog Feb 06 '19 at 17:37
  • EDN does not support inclusion by itself. – akond Feb 06 '19 at 17:57
1

You might find the aero library from JUXT useful. It adds some custom tag literals to facilitate using EDN files for configuration. One of these is #include, which sounds like it does just what you need.

ray1729
  • 41
  • 3