--- linum.el.orig 2011-01-09 02:45:14.000000000 +0900 +++ linum.el 2011-05-06 21:24:13.338622400 +0900 @@ -146,26 +146,38 @@ ;; 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)))) + (unless (and (invisible-p (point)) + (catch 'invisible-p + (save-excursion + (let* ((inhibit-field-text-motion t) + (eol (line-end-position))) + (while (not (eolp)) + (goto-char + (next-single-char-property-change + (point) 'invisible nil eol)) + (unless (invisible-p (point)) + (throw 'invisible-p nil))) + t)))) ; current line is invisible entirely ? + (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))))) ;; Text may contain those nasty intangible properties, but that ;; shouldn't prevent us from counting those lines. (let ((inhibit-point-motion-hooks t))