GNU bug report logs - #743
23.0.60; linum-mode margin display wrong

Previous Next

Package: emacs;

Reported by: bojohan+mail <at> dd.chalmers.se (Johan Bockgård)

Date: Tue, 19 Aug 2008 19:35:03 UTC

Severity: normal

Done: Chong Yidong <cyd <at> stupidchicken.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 743 in the body.
You can then email your comments to 743 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#743; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to bojohan+mail <at> dd.chalmers.se (Johan Bockgård):
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: bojohan+mail <at> dd.chalmers.se (Johan Bockgård)
To: emacs-pretest-bug <at> gnu.org
Subject: 23.0.60; linum-mode margin display wrong
Date: Tue, 19 Aug 2008 21:29:39 +0200
$ emacs -Q -eval '(progn (linum-mode 1) (insert-char ?\n 100) (goto-line 12) (redisplay) (kill-line 10))'

The numbering in the margin of the first lines looks like:

  |
  |
  |
  |
  |
  |
  |
  |
  |
 1|
 1|
 1|
13|
14|
...

The first 12 lines have a display margin string that is 3 characters
long (space padded), but the margin is only 2 columns wide, so the last
digit is lost.

-- 
Johan Bockgård




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#743; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to Chong Yidong <cyd <at> stupidchicken.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #10 received at 743 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Chong Yidong <cyd <at> stupidchicken.com>
To: Markus Triska <markus.triska <at> gmx.at>
Cc: 743 <at> debbugs.gnu.org
Subject: Re: 23.0.60; linum-mode margin display wrong
Date: Wed, 20 Aug 2008 18:27:40 -0400
Hi Markus,

Could you try to debug this?  I'm not sure if it's a linum.el bug or a
redisplay bug.

> $ emacs -Q -eval '(progn (linum-mode 1) (insert-char ?\n 100) (goto-line 12) (redisplay) (kill-line 10))'
>
> The numbering in the margin of the first lines looks like:
>
>   |
>   |
>   |
>   |
>   |
>   |
>   |
>   |
>   |
>  1|
>  1|
>  1|
> 13|
> 14|
> ...
>
> The first 12 lines have a display margin string that is 3 characters
> long (space padded), but the margin is only 2 columns wide, so the last
> digit is lost.




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#743; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to Markus Triska <markus.triska <at> gmx.at>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #15 received at 743 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Markus Triska <markus.triska <at> gmx.at>
To: Chong Yidong <cyd <at> stupidchicken.com>
Cc: 743 <at> debbugs.gnu.org
Subject: Re: 23.0.60; linum-mode margin display wrong
Date: Thu, 21 Aug 2008 01:16:31 -0400
Chong Yidong <cyd <at> stupidchicken.com> writes:

> Could you try to debug this?  I'm not sure if it's a linum.el bug or a
> redisplay bug.

I cannot reproduce this when I add "-nw". Does that help?




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#743; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to Markus Triska <markus.triska <at> gmx.at>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #20 received at 743 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Markus Triska <markus.triska <at> gmx.at>
To: Chong Yidong <cyd <at> stupidchicken.com>
Cc: 743 <at> debbugs.gnu.org
Subject: Re: 23.0.60; linum-mode margin display wrong
Date: Thu, 21 Aug 2008 08:16:09 -0400
> I cannot reproduce this when I add "-nw".

I've now found a similar problem that occurs with "-nw" - this is
definitely a linum.el problem, and I will provide a fix soon.




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#743; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to Markus Triska <markus.triska <at> gmx.at>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #25 received at 743 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Markus Triska <markus.triska <at> gmx.at>
To: Chong Yidong <cyd <at> stupidchicken.com>
Cc: 743 <at> debbugs.gnu.org
Subject: Re: 23.0.60; linum-mode margin display wrong
Date: Thu, 21 Aug 2008 21:49:00 -0400
Chong Yidong <cyd <at> stupidchicken.com> writes:

> Could you try to debug this?  I'm not sure if it's a linum.el bug or a
> redisplay bug.

The following patch fixes this problem for me. One remaining issue is
that overlays for line numbers inherit text properties. For example:

   $ emacs -Q -f fundamental-mode -f linum-mode

   M-o u

then insert anything, and the line number is also underlined. How to
best fix this? Maybe overlays should not inherit properties if they only
affect the display margins.


2008-08-22  Markus Triska  <markus.triska <at> gmx.at>

	* linum.el (linum-delay): Disable - it should no longer be
	necessary, and can lead to longer delays.
	(linum-update-window): Renumber if margin width has changed.

diff --git a/lisp/linum.el b/lisp/linum.el
index 41fe2de..db07b00 100644
--- a/lisp/linum.el
+++ b/lisp/linum.el
@@ -30,7 +30,7 @@
 
 ;;; Code:
 
-(defconst linum-version "0.9wx")
+(defconst linum-version "0.9wz")
 
 (defvar linum-overlays nil "Overlays used in this buffer.")
 (defvar linum-available nil "Overlays available for reuse.")
@@ -65,7 +65,7 @@ and you have to scroll or press \\[recenter-top-bottom] to update the numbers."
   :group 'linum
   :type 'boolean)
 
-(defcustom linum-delay t
+(defcustom linum-delay nil
   "Delay updates to give Emacs a chance for other changes."
   :group 'linum
   :type 'boolean)
@@ -131,39 +131,38 @@ and you have to scroll or press \\[recenter-top-bottom] to update the numbers."
   "Update line numbers for the portion visible in window WIN."
   (goto-char (window-start win))
   (let ((line (line-number-at-pos))
-        (limit (1+ (window-end win t)))
+        (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)
-        visited
-        ov)
+        (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))
-      (setq visited nil)
-      (dolist (o (overlays-in (point) (point)))
-        (when (eq (overlay-get o 'linum-line) line)
-          (unless (memq o linum-overlays)
-            (push o linum-overlays))
-          (setq linum-available (delete o linum-available))
-          (setq visited t)))
-      (let ((str (if fmt
-                     (propertize (format fmt line) 'face 'linum)
-                   (funcall linum-format line))))
+    (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 (string= (overlay-get o 'linum-str) str)
+                            (unless (memq o linum-overlays)
+                              (push o linum-overlays))
+                            (setq linum-available (delete o linum-available))
+                            (throw 'visited t))))))
         (setq width (max width (length str)))
         (unless visited
-          (if (null linum-available)
-              (setq ov (make-overlay (point) (point)))
-            (setq ov (pop linum-available))
-            (move-overlay ov (point) (point)))
-          (push ov linum-overlays)
-          (setq str (propertize " " 'display `((margin left-margin) ,str)))
-          (overlay-put ov 'before-string str)
-          (overlay-put ov 'linum-line line)))
+          (let (ov)
+            (if (null linum-available)
+                (setq ov (make-overlay (point) (point)))
+              (setq ov (pop linum-available))
+              (move-overlay ov (point) (point)))
+            (push ov linum-overlays)
+            (overlay-put ov 'before-string
+                         (propertize " " 'display `((margin left-margin) ,str)))
+            (overlay-put ov 'linum-str str))))
       (forward-line)
       (setq line (1+ line)))
     (set-window-margins win width)))





Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#743; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to bojohan+mail <at> dd.chalmers.se (Johan Bockgård):
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #30 received at 743 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: bojohan+mail <at> dd.chalmers.se (Johan Bockgård)
To: 743 <at> debbugs.gnu.org
Subject: Re: bug#743: 23.0.60; linum-mode margin display wrong
Date: Fri, 22 Aug 2008 20:41:31 +0200
Markus Triska <markus.triska <at> gmx.at> writes:

> One remaining issue is that overlays for line numbers inherit text
> properties. For example:
>
>    $ emacs -Q -f fundamental-mode -f linum-mode
>
>    M-o u
>
> then insert anything, and the line number is also underlined. How to
> best fix this?

Try this:

    (defface linum
      '((t :inherit (shadow default)))
      "Face for displaying line numbers in the display margin."
      :group 'linum)

-- 
Johan Bockgård




Reply sent to Chong Yidong <cyd <at> stupidchicken.com>:
You have taken responsibility. Full text and rfc822 format available.

Notification sent to bojohan+mail <at> dd.chalmers.se (Johan Bockgård):
bug acknowledged by developer. Full text and rfc822 format available.

Message #35 received at 743-done <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Chong Yidong <cyd <at> stupidchicken.com>
To: Markus Triska <markus.triska <at> gmx.at>
Cc: bojohan+mail <at> dd.chalmers.se (Johan Bockgård),
        743-done <at> debbugs.gnu.org
Subject: Re: bug#743: 23.0.60; linum-mode margin display wrong
Date: Tue, 26 Aug 2008 16:53:13 -0400
> The following patch fixes this problem for me.

I've checked in the patch, together with Johan's suggestion of
inheriting the remaining face attributes of `linum' from the default
face.

Thanks.




bug archived. Request was from Debbugs Internal Request <don <at> donarmstrong.com> to internal_control <at> emacsbugs.donarmstrong.com. (Wed, 24 Sep 2008 14:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 16 years and 271 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.