bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#17787: 24.4.50; Making `linum-mode` more efficient -- no need to run


From: Keith David Bershatsky
Subject: bug#17787: 24.4.50; Making `linum-mode` more efficient -- no need to run multiple times.
Date: Sun, 15 Jun 2014 15:03:17 -0700

Thank you for the referral to the library `nlinum-mode`.  I've downloaded it 
and tried it out, and will keep it in my ever growing bag of goodies.  I'll 
need to try it out over time with my various minor modes to see how they play 
together.

I understand that the Emacs team may wish to discontinue `linum-mode` in favor 
of `nlinum-mode`, so this bug report (#17787) can be closed out at your 
convenience.

I've gone ahead and made a first draft of the fix to `linum-mode`, which is 
dependent upon the global variable `scroll-margin` being set to zero (as that 
is the circumstance whereby the `window-scroll-functions` hook makes a second 
run).  When the `scroll-margin` is set to something like 2 (instead of zero), 
the condition `(not (> (point) (window-end win t)))` will prevent the function 
from working.


Thanks,

Keith

(defun linum-update-current ()
  (when
      (and
        (not (minibufferp))
        (window-live-p (get-buffer-window (current-buffer))))
    (setq old-window-start (window-start))
    (setq old-window-end (window-end))
    (setq old-window-end-forced (window-end nil t))
    (when
        (and
          (not (< (point) old-window-start))
          (not (> (point) old-window-end))
          (not (> (point) old-window-end-forced)))
      (linum-update (current-buffer)))))

(defun linum-after-scroll (win _start)
  (when
      (and
        (not (> (point) (window-end win t))) ;; contingent upon `scroll-margin 
0`
        old-window-start
        old-window-end
        old-window-end-forced
        (not (minibufferp))
        (window-live-p (get-buffer-window (current-buffer))))
    (when
        (or
          (< (point) old-window-start)
          (> (point) old-window-end)
          (> (point) old-window-end-forced))
      (let* (
          (new-window-start _start)
          (new-window-end (window-end win t)))
        (linum-update (window-buffer win))
        (setq old-window-start nil)
        (setq old-window-end nil)
        (setq old-window-end-forced nil)))))


---------------------------------------

On Jun 15, 2014, at 12:54 PM, Eli Zaretskii wrote:

>> Date: Sun, 15 Jun 2014 12:11:52 -0700
>> From: Keith David Bershatsky <esq@lawlist.com>
>> 
>> Linum-mode could be made more efficient [...]
> 
> Can I persuade you (and everyone else) to please forget linum-mode
> ever existed, and never to remember that?  If someone wants line
> numbers in Emacs, could they please use Stefan's nlinum-mode instead?





reply via email to

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