CM6: How do I get lines between a range?

I’ve been playing around with doc.line() and doc.lineAt() APIs.

Is there a straightforward way to iterate all lines (or get a line range like [3, 5]) from a selection range (from, to) ?

Not really. What do you mean by “iterate all lines from a selection range”? You can keep calling doc.lineAt(prevLine.to + 1) to skip to the next line, if you want to.