emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Temporarily select-window, without updating mode-line face and curso


From: JD Smith
Subject: Re: Temporarily select-window, without updating mode-line face and cursor fill?
Date: Tue, 4 May 2021 15:28:57 -0400


On May 2, 2021, at 10:25 PM, Stefan Monnier <monnier@iro.umontreal.ca> wrote:

(setq nlinum--line-number-cache nil))

Taking a closer look at Stefan’s idea here, and considering the concerns people have about the set-window-point/format-mode-line approach, I have implemented a new caching system based on nlinum, with the regular old line-number-at-pos and count-lines underneath; see:

https://github.com/jdtsmith/mlscroll/blob/07a657d28d779c3bc56b0a2ea04cfc6d23c54897/mlscroll.el#L87

Neither format-mode-line nor window-point manipulation is needed now.  Unlike nlinum, it also does not require an after-change-function, opting instead to save a buffer tick and point-min/max to look for buffer modifications and any narrowing/widening.  In practice it entirely solves the long file scrolling bottleneck, since effectively all line lookups during scrolling hit the cache, and cached computation of all 3 line positions is >50x faster than even format-mode-line was.

Thanks all for your suggestions/criticism/feedback.  What I can conclude is that the default approach line-number-at-pos takes of “counting all newlines from the start of the file” is really painfully inefficient.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]