1
0
Fork 0
mirror of https://github.com/emacs-twist/org-babel.git synced 2025-03-14 20:56:34 +00:00
org-babel/nix/excludeOrgSubtreesOnHeadlines.nix

22 lines
411 B
Nix
Raw Normal View History

2021-12-03 22:44:34 +09:00
# Exclude lines of Org subtrees by a heading predicate
pred:
with builtins;
let
inherit (import ./utils.nix)
dropTillSubtreeEnd
getHeadlineLevel
splitListWith
isHeadline;
2021-12-03 22:44:34 +09:00
go_ = cut:
cut.before
++
(if cut.sep == null
then [ ]
else go (dropTillSubtreeEnd (getHeadlineLevel cut.sep) cut.after));
go = lines: go_ (splitListWith (s: isHeadline s && pred s) lines);
in
go