all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#27622: Trying to improve the speed of linum-mode
@ 2017-07-08  9:25 Fis Trivial
  2017-07-08 17:01 ` Eli Zaretskii
  0 siblings, 1 reply; 11+ messages in thread
From: Fis Trivial @ 2017-07-08  9:25 UTC (permalink / raw)
  To: 27622

For some reasons, the linum-mode needs to go over the whole buffer in
order to update the line numbers. It's ok when viewing a small buffer,
but when comes to something large it will slow the emacs down like I
was viewing a ppt(try kernel patch). I don't really understand the
code, but I changed it a little bit and it works fine so far. Here is
the patch, linum-o.el is the original code:




--- linum-o.el	2017-06-06 09:04:32.012568000 +0800
+++ linum.el	2017-07-
08 16:45:45.710518928 +0800
@@ -174,7 +174,7 @@
         (fmt (cond
((stringp linum-format) linum-format)
                    ((eq linum-
format 'dynamic)
                     (let ((w (length (number-to-string

-                                      (count-lines (point-min) (point-
max))))))
+                                      (count-lines (window-
start win) (window-end win t))))))
                       (concat "%"
(number-to-string w) "d")))))
         (width 0))
     (run-hooks 'linum-
before-numbering-hook)




The minor change replaced (point-min/max) to (window-start/end) which
saves a lots of iterations and did improve the speed at start-up. but
if I move the cursor to the end of the buffer, it slows down again and
I don't know why it's happening.
So, I got wonder is there any particular reason to use (point-min)
instead of (window-start)? And what's the cause of slowing down when I
move the cursor to the end of buffer?

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

end of thread, other threads:[~2017-07-31  3:11 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-08  9:25 bug#27622: Trying to improve the speed of linum-mode Fis Trivial
2017-07-08 17:01 ` Eli Zaretskii
     [not found]   ` <BN6PR16MB1859AD697302D7AD9BCFE79D92AB0@BN6PR16MB1859.namprd16.prod.outlook.com>
2017-07-08 18:55     ` Eli Zaretskii
     [not found]       ` <BN6PR16MB1859941C3153757777556D4192AB0@BN6PR16MB1859.namprd16.prod.outlook.com>
2017-07-08 19:44         ` Eli Zaretskii
     [not found]           ` <BN6PR16MB185932C3CF6DFA06F47DAA8A92AB0@BN6PR16MB1859.namprd16.prod.outlook.com>
2017-07-09 14:39             ` Eli Zaretskii
2017-07-09 18:06               ` Fis Trivial
2017-07-09 18:27                 ` Eli Zaretskii
2017-07-09 23:29   ` Glenn Morris
2017-07-10 16:50     ` Eli Zaretskii
2017-07-31  2:06       ` Glenn Morris
2017-07-31  3:11         ` Eli Zaretskii

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.