This is an interesting solution, however... I might have some use cases where this will fail, for example if SOURCES = ... happens to be the very last block in the file (i.e. there IS no next marker, other than EOF).
Or, if the next marker is also one I might want to grab in a different pass, but I don't know the order of them to know what order to put the /BEGIN/ and /END/ range markers in.
I'll hit this with a few broad examples and see if it works when I intentionally try to break it with different constructs.