To be clear, Jean, are you conducting this review for Non-GNU ELPA?
> I think that longer lines shall be wrapped, you have to include word
> wrap, as otherwise lines will become smaller thant the original line!
Such a change is in progress. I'm just about to stash some re-work of the core logic for `moc-focus' to have general support for most cases. It's looking like 1k lines of rework and quite annoying. I suspect there must be a better way.
I can fit visual lines by using their horizontal and vertical height after breaks to calculate what will provide the best aspect ratio. Such a calculation with reasonable accuracy can be done in one step without troubling Emacs. With some length of selection there is never anything I can do to make the text big, but we can make it pretty.
The fundamental issue remains that translating overlays after such a reflow is not so trivial. That is unless I do the reflow within a buffer with editing commands after copying all of the necessary information over instead of stitching and welding overlays and strings together without the aid of a buffer. This would allow some savings by re-using editing logic to preserve overlays and property applications to injected whitespace. Instead of calculating things I can just read the final result of all the edits. This seems more robust and I think I will implement the easiest and most relevant cases first:
- whitespace trimming of indentation
- whitespace injection to maintain column alignment of first line in source
- newline insertion to reflow long logical lines and match the target aspect ratio
I might just need a break lol.