Skip to main content
added 11 characters in body
Source Link
tefkah
  • 111
  • 6

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: enter image description here

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.

I want to insert an overlay at the beginning of every 40th or so visual/screen, to generate a WYSIWYG looking overlay like so: enter image description here

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.

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: enter image description here

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.

Source Link
tefkah
  • 111
  • 6

How to insert overlay every n visual/screen lines?

I want to insert an overlay at the beginning of every 40th or so visual/screen, to generate a WYSIWYG looking overlay like so: enter image description here

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.