unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Most efficient way of getting position of visual-line?
@ 2021-07-06  7:45 Thomas F. K. Jorna
  2021-07-06  9:16 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-06 11:33 ` Eli Zaretskii
  0 siblings, 2 replies; 3+ messages in thread
From: Thomas F. K. Jorna @ 2021-07-06  7:45 UTC (permalink / raw)
  To: help-gnu-emacs

Hello!

For a package I'm developing I need to insert an overlay every n visual 
lines. The fastest way of obtaining the positions of those lines I found 
is something like

  (let ((vl-list '(0))
         (n 10))
   (save-excursion
     (goto-line (point-min))
     (dotimes (line (/ (count-screen-lines) n))
       (vertical-motion n)
       (setq vl-list (append vl-list (list (point))))))


Perhaps not the most elegant written, but I've found no faster way than 
simply scrolling somewhere using vertical-motion

I had hoped that compute-motion could help me, but that does not seem to 
work well with word-wrapping, as that causes the width of the lines to 
change.

Ideally I would use something like what display-line-numbers-mode uses 
for its 'visual setting, but I have to admit that reading the source 
code is still a bit beyond me, in addition to the fact that those 
methods do not seem accessible from outsidedisplay-line-numbers-mode.

Anyone have any better ways of solving this? Thank you for your time!

- Thomas F. K. Jorna





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-07-06 11:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-06  7:45 Most efficient way of getting position of visual-line? Thomas F. K. Jorna
2021-07-06  9:16 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-06 11:33 ` Eli Zaretskii

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).