mirror of
https://github.com/emacs-twist/org-babel.git
synced 2025-03-05 08:17:05 +00:00
21 lines
411 B
Nix
21 lines
411 B
Nix
# Exclude lines of Org subtrees by a heading predicate
|
|
pred:
|
|
with builtins;
|
|
let
|
|
inherit (import ./utils.nix)
|
|
dropTillSubtreeEnd
|
|
getHeadlineLevel
|
|
splitListWith
|
|
isHeadline;
|
|
|
|
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
|