At WWDC 2013 it was noted a few times that Text Kit would simplify advanced techniques like text folding. But no sample code was offered for that particular session (220), and repeated searches on how to do this have been mostly unfruitful.
What I'd like to accomplish is to hit tab on a header line (Markdown or Org-Mode style) and have it fold all the text up to the next header line.
I can intercept the call to "insertTab" using an NSTextView subclass, and then use a regular expression to check whether or not the tab happened on a header line. If it did, I use another regex to determine the range up to the subsequent header line. But which methods (I'm assuming on NSLayoutManager - or NSTypeSetter or NSGlyphGenerator) do I call to perform the folding?