[Top][All Lists]

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

bug#4996: problem found

From: Mark Lillibridge
Subject: bug#4996: problem found
Date: Fri, 20 Nov 2009 22:24:17 -0800

    Ok, I have a proposed patch for linum.el that solves the problem
with it displaying incorrect line numbers in the presence of intangible

The original version of linum.el has:

(defun linum-update-window (win)
  "Update line numbers for the portion visible in window WIN."
  (goto-char (window-start win))
  (let ((line (line-number-at-pos))
        (limit (window-end win t))
        (fmt (cond ((stringp linum-format) linum-format)
                   ((eq linum-format 'dynamic)
                    (let ((w (length (number-to-string
                                      (count-lines (point-min) (point-max))))))
                      (concat "%" (number-to-string w) "d")))))
        (width 0))
    (run-hooks 'linum-before-numbering-hook)
    ;; Create an overlay (or reuse an existing one) for each
    ;; line visible in this window, if necessary.
    (while (and (not (eobp)) (<= (point) limit))
      (let* ((str (if fmt
                      (propertize (format fmt line) 'face 'linum)
                    (funcall linum-format line)))
             (visited (catch 'visited
                        (dolist (o (overlays-in (point) (point)))
                          (when (equal-including-properties
                                 (overlay-get o 'linum-str) str)
                            (unless (memq o linum-overlays)
                              (push o linum-overlays))
                            (setq linum-available (delq o linum-available))
                            (throw 'visited t))))))
        (setq width (max width (length str)))
        (unless visited
          (let ((ov (if (null linum-available)
                        (make-overlay (point) (point))
                      (move-overlay (pop linum-available) (point) (point)))))
            (push ov linum-overlays)
            (overlay-put ov 'before-string
                         (propertize " " 'display `((margin left-margin) ,str)))
            (overlay-put ov 'linum-str str))))
      (setq line (1+ line)))
    (set-window-margins win width)))

The problem here is the third to last line,


Linum assumes this will move at most one logical line forward, when
in the presence of intangible text it can move an arbitrary number of
logical lines forward.  *BUG*

I propose changing that line to:

      (let ((old-inhibit inhibit-point-motion-hooks))
        (setq inhibit-point-motion-hooks t)
        (setq inhibit-point-motion-hooks old-inhibit))

    I have verified that this causes the correct line numbers to be
shown, both with and without being called via the scrolling hook.


- Mark

reply via email to

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