I want to insert an overlay at the beginning of every 40th or so visual/screen, to generate a WYSIWYG looking page-break overlay like so:
At the moment this is done by font-locking the line-feed character (with overlays), which works but it edits the text and makes the overlay too concrete. Ideally I would have a minor-mode running which inserts overlays at the start of every nth visual line to prevent this.
While I found how to move x number of screen lines or get x number of screen lines in a certain region, https://www.gnu.org/software/emacs/manual/html_node/elisp/Screen-Lines.html, I have not been able to figure out how get that position so that I can use it in the declaration of the overlay. Maybe this is doable with some complicated compute-motion
, but I am not exactly sure how that would work.
Any ideas?
This is a partial copy of Obtain points at beginning/ending of visual line without using vertical-motion, but that question specifically concerns obtaining the beginning/end of the current line, not any line. While I could iterate over the entire file and obtain those coordinates, that is obviously not very feasible.
follow-mode
, but perhaps that would be something that you might be interested in -- essentially there are two (2) windows and the divider between those windows could serve as a page break ....centered-cursor-mode
and see what makes it tick. Instead of centering the cursor, you could place your overlays to achieve the desired visual effect. There may already be an adjustment built-in to that minor-mode to select a screen position other than dead center ...