unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Redisplay bug in margin
@ 2007-09-19 11:16 Juanma Barranquero
  2007-09-20 16:35 ` Richard Stallman
  0 siblings, 1 reply; 12+ messages in thread
From: Juanma Barranquero @ 2007-09-19 11:16 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 671 bytes --]

While trying Markus Triska's linum.el, I've stumbled upon a redisplay
bug in the window margin.

I'm using

  GNU Emacs 23.0.50.1 (i386-mingw-nt5.1.2600) of 2007-09-19 on JUANMAB

compiled with

  gcc (GCC) 3.4.5 (mingw special)

A simple way to see the bug:

----- .emacs -----
(require 'linum)   ;; a recent version

(setq linum-format
      (lambda (line)
	(propertize (format "%d" line) 'face 'linum)))

(setq confirm-kill-emacs 'y-or-n-p)
------------------

And then:

 emacs
 M-x linum-mode <RET>   ;; while on the Welcome screen
 C-x C-c

Strictly speaking, it is not required to set `linum-format', but it is
easier to see the bug that way.

             Juanma

[-- Attachment #2: before.png --]
[-- Type: image/png, Size: 3750 bytes --]

[-- Attachment #3: after.png --]
[-- Type: image/png, Size: 3841 bytes --]

[-- Attachment #4: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

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

* Re: Redisplay bug in margin
  2007-09-19 11:16 Redisplay bug in margin Juanma Barranquero
@ 2007-09-20 16:35 ` Richard Stallman
  2007-09-20 22:01   ` Stephen Berman
  0 siblings, 1 reply; 12+ messages in thread
From: Richard Stallman @ 2007-09-20 16:35 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: emacs-devel

Does the bug happen in Emacs 22.1?

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

* Re: Redisplay bug in margin
  2007-09-20 16:35 ` Richard Stallman
@ 2007-09-20 22:01   ` Stephen Berman
  2007-09-23  9:07     ` Richard Stallman
  0 siblings, 1 reply; 12+ messages in thread
From: Stephen Berman @ 2007-09-20 22:01 UTC (permalink / raw)
  To: emacs-devel

On Thu, 20 Sep 2007 12:35:14 -0400 Richard Stallman <rms@gnu.org> wrote:

> Does the bug happen in Emacs 22.1?

Yes.  (But the recipe to show it is a bit different, since in 22.1 the
splash screen disappears as soon as you start to type M-x linum-mode.
So first open the menu item Help->About Emacs, the do M-x linum-mode.
The rest of the recipe is the same and so is the redisplay bug.)

Steve Berman

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

* Re: Redisplay bug in margin
  2007-09-20 22:01   ` Stephen Berman
@ 2007-09-23  9:07     ` Richard Stallman
  2007-09-23 14:27       ` Stephen Berman
  0 siblings, 1 reply; 12+ messages in thread
From: Richard Stallman @ 2007-09-23  9:07 UTC (permalink / raw)
  To: Stephen Berman; +Cc: emacs-devel

Can you send a self-contained complete test case for Emacs 22.1,
including a copy of a version of linum that causes the failure?
That is the way to make debugging reliable.

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

* Re: Redisplay bug in margin
  2007-09-23  9:07     ` Richard Stallman
@ 2007-09-23 14:27       ` Stephen Berman
  2007-09-23 21:54         ` Richard Stallman
  0 siblings, 1 reply; 12+ messages in thread
From: Stephen Berman @ 2007-09-23 14:27 UTC (permalink / raw)
  To: emacs-devel

On Sun, 23 Sep 2007 05:07:46 -0400 Richard Stallman <rms@gnu.org> wrote:

> Can you send a self-contained complete test case for Emacs 22.1,
> including a copy of a version of linum that causes the failure?
> That is the way to make debugging reliable.

With linum.el version 0.9u+ (the latest version as of this posting),
Emacs 22.1 does not show the display bug.  When I posted, I had tested
with linum.el version 0.9t, which does show the bug.  For the record,
here is the recipe:

1. Save the following lines  ~/linum-test.el:

(load-file "<path/to/linum.el>") ;; linum.el version 0.9t
(setq linum-format
      (lambda (line)
	(propertize (format "%d" line) 'face 'linum)))
(setq confirm-kill-emacs 'y-or-n-p)

2. emacs -q -l ~/linum-test.el ;; Emacs 22.1

3. M-x display-splash-screen

4. M-x linum-mode

5. C-x C-c

Now the display bug is seen.

Unlike Emacs 22.1, my current CVS Emacs (from the trunk) shows the bug
also with the current linum.el version 0.9u+ (GNU Emacs 23.0.50.1
(i686-pc-linux-gnu, GTK+ Version 2.10.6) of 2007-09-23).

Steve Berman

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

* Re: Redisplay bug in margin
  2007-09-23 14:27       ` Stephen Berman
@ 2007-09-23 21:54         ` Richard Stallman
  2007-09-23 22:49           ` Stephen Berman
  0 siblings, 1 reply; 12+ messages in thread
From: Richard Stallman @ 2007-09-23 21:54 UTC (permalink / raw)
  To: Stephen Berman; +Cc: emacs-devel

    (load-file "<path/to/linum.el>") ;; linum.el version 0.9t

That's not complete.  Could you post it again with a copy
of the requisite linum.el code?

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

* Re: Redisplay bug in margin
  2007-09-23 21:54         ` Richard Stallman
@ 2007-09-23 22:49           ` Stephen Berman
  2007-09-24 18:19             ` Richard Stallman
  0 siblings, 1 reply; 12+ messages in thread
From: Stephen Berman @ 2007-09-23 22:49 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1045 bytes --]

On Sun, 23 Sep 2007 17:54:35 -0400 Richard Stallman <rms@gnu.org> wrote:

>     (load-file "<path/to/linum.el>") ;; linum.el version 0.9t
>
> That's not complete.  Could you post it again with a copy
> of the requisite linum.el code?

Sorry, I had misread "including a copy of a version of linum that
causes the failure" as requesting just the version number.  I attach
linum.el version 0.9t to this message; but again, note that the latest
version, 0.9u+ does not show the bug with Emacs 22.1 (though both
versions 0.9t and 0.9u+ show it with CVS Emacs from the trunk).  For
comparison, I also attach a diff between versions 0.9t and 0.9u+.  And
for completeness, here's the recipe again:

1. Save the following lines to  ~/linum-test.el:

(load-file "<path/to/linum.el>") ;; linum.el version 0.9t
(setq linum-format
      (lambda (line)
	(propertize (format "%d" line) 'face 'linum)))
(setq confirm-kill-emacs 'y-or-n-p)

2. emacs -q -l ~/linum-test.el ;; Emacs 22.1

3. M-x display-splash-screen

4. M-x linum-mode

5. C-x C-c

Steve Berman


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: linum.el version 0.9t --]
[-- Type: text/x-emacs-lisp, Size: 6940 bytes --]

;;; linum.el --- Display line numbers to the left of buffers

;; Copyright (C) 2007  Markus Triska

;; Author: Markus Triska <markus.triska@gmx.at>
;; Keywords: convenience

;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.

;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.

;;; Commentary:

;; Display line numbers for the current buffer. Copy linum.el to your
;; load-path and add to your .emacs:

;;    (require 'linum)

;; Then toggle display of line numbers with M-x linum-mode.

;;; Code:

(defconst linum-version "0.9t")

(defvar linum-overlays nil "Overlays used in this buffer.")
(defvar linum-available nil "Overlays available for reuse.")
(defvar linum-before-numbering nil
  "Functions run in each buffer before line numbering starts.")

(mapc #'make-variable-buffer-local '(linum-overlays linum-available))

(defgroup linum nil
  "Show line numbers to the left of buffers"
  :group 'convenience)

;;;###autoload
(defcustom linum-format 'dynamic
  "Format used to display line numbers. Either a format string
like \"%7d\", 'dynamic to adapt the width as needed, or a
function that is called with a line number as its argument and
should evaluate to a string to be shown on that line. See also
`linum-before-numbering'."
  :group 'linum
  :type 'sexp)

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

(defcustom linum-eager t
  "Whether line numbers should be updated after each command.
The conservative setting `nil' might miss some buffer changes,
and you have to scroll or press C-l to update the numbers."
  :group 'linum
  :type 'boolean)

(defcustom linum-delay t
  "Whether updates should be delayed to give Emacs a chance for
other changes."
  :group 'linum
  :type 'boolean)

;;;###autoload
(define-minor-mode linum-mode
  "Toggle display of line numbers in the left marginal area."
  :lighter ""                           ; for desktop.el
  (if linum-mode
      (progn
        (if linum-eager
            (add-hook 'post-command-hook (if linum-delay
                                             'linum-schedule
                                           'linum-update-current) nil t)
          (add-hook 'after-change-functions 'linum-after-change nil t))
        (add-hook 'window-scroll-functions 'linum-after-scroll nil t)
        (add-hook 'window-size-change-functions 'linum-after-size)
        (add-hook 'change-major-mode-hook 'linum-delete-overlays nil t)
        (add-hook 'window-configuration-change-hook
                  'linum-after-config nil t)
        (linum-update-current)
        (message "Linum mode enabled"))
    (remove-hook 'post-command-hook 'linum-update-current t)
    (remove-hook 'post-command-hook 'linum-schedule t)
    (remove-hook 'window-size-change-functions 'linum-after-size)
    (remove-hook 'window-scroll-functions 'linum-after-scroll t)
    (remove-hook 'after-change-functions 'linum-after-change t)
    (remove-hook 'window-configuration-change-hook 'linum-after-config t)
    (remove-hook 'change-major-mode-hook 'linum-delete-overlays t)
    (linum-delete-overlays)
    (message "Linum mode disabled")))

;;;###autoload
(define-globalized-minor-mode global-linum-mode linum-mode linum-on)

(defun linum-on ()
  (unless (minibufferp)
    (linum-mode 1)))

(defun linum-delete-overlays ()
  "Delete all overlays displaying line numbers for this buffer."
  (mapc #'delete-overlay linum-overlays)
  (setq linum-overlays nil)
  (dolist (w (get-buffer-window-list (current-buffer) nil t))
    (set-window-margins w 0)))

(defun linum-update-current ()
  "Update line numbers for the current buffer."
  (linum-update (current-buffer)))

(defun linum-update (buffer)
  "Update line numbers for all windows displaying BUFFER."
  (with-current-buffer buffer
    (when linum-mode
      (setq linum-available linum-overlays)
      (setq linum-overlays nil)
      (save-excursion
        (mapc #'linum-update-window
              (get-buffer-window-list buffer nil 'visible)))
      (mapc #'delete-overlay linum-available)
      (setq linum-available nil))))

(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 (1+ (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)
        ov)
    (run-hooks 'linum-before-numbering)
    ;; Create an overlay (or reuse an existing one) for each
    ;; line visible in this window.
    (while (and (not (eobp)) (< (point) limit))
      (let ((str (if fmt
                   (propertize (format fmt line) 'face 'linum)
                 (funcall linum-format line))))
        (setq width (max width (length str)))
        (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))
      (forward-line)
      (setq line (1+ line)))
    (set-window-margins win width)))

(defun linum-after-change (beg end len)
  ;; update overlays on deletions, and after newlines are inserted
  (when (or (= beg end)
            (= end (point-max))
            ;; TODO: use string-match-p with CVS or new release
            (string-match "\n" (buffer-substring-no-properties beg end)))
    (linum-update-current)))

(defun linum-after-scroll (win start)
  (linum-update (window-buffer win)))

(defun linum-after-size (frame)
  (linum-after-config))

(defun linum-schedule ()
  ;; schedule an update; the delay gives Emacs a chance for display changes
  (run-with-idle-timer 0 nil #'linum-update-current))

(defun linum-after-config ()
  (walk-windows (lambda (w)
                  (with-current-buffer (window-buffer w)
                    (when linum-mode
                      (save-excursion
                        (linum-update-window w))))) nil 'visible))

(provide 'linum)
;;; linum.el ends here

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: linum-09t-09u+.diff --]
[-- Type: text/x-patch, Size: 2805 bytes --]

*** linum.el	2007-09-16 16:29:19.000000000 +0200	version 0.9t
--- linum.el	2007-09-23 14:44:19.000000000 +0200	version 0.9u+
***************
*** 31,37 ****
  
  ;;; Code:
  
! (defconst linum-version "0.9t")
  
  (defvar linum-overlays nil "Overlays used in this buffer.")
  (defvar linum-available nil "Overlays available for reuse.")
--- 31,37 ----
  
  ;;; Code:
  
! (defconst linum-version "0.9u+")
  
  (defvar linum-overlays nil "Overlays used in this buffer.")
  (defvar linum-available nil "Overlays available for reuse.")
***************
*** 88,95 ****
          (add-hook 'change-major-mode-hook 'linum-delete-overlays nil t)
          (add-hook 'window-configuration-change-hook
                    'linum-after-config nil t)
!         (linum-update-current)
!         (message "Linum mode enabled"))
      (remove-hook 'post-command-hook 'linum-update-current t)
      (remove-hook 'post-command-hook 'linum-schedule t)
      (remove-hook 'window-size-change-functions 'linum-after-size)
--- 88,94 ----
          (add-hook 'change-major-mode-hook 'linum-delete-overlays nil t)
          (add-hook 'window-configuration-change-hook
                    'linum-after-config nil t)
!         (linum-update-current))
      (remove-hook 'post-command-hook 'linum-update-current t)
      (remove-hook 'post-command-hook 'linum-schedule t)
      (remove-hook 'window-size-change-functions 'linum-after-size)
***************
*** 97,104 ****
      (remove-hook 'after-change-functions 'linum-after-change t)
      (remove-hook 'window-configuration-change-hook 'linum-after-config t)
      (remove-hook 'change-major-mode-hook 'linum-delete-overlays t)
!     (linum-delete-overlays)
!     (message "Linum mode disabled")))
  
  ;;;###autoload
  (define-globalized-minor-mode global-linum-mode linum-mode linum-on)
--- 96,102 ----
      (remove-hook 'after-change-functions 'linum-after-change t)
      (remove-hook 'window-configuration-change-hook 'linum-after-config t)
      (remove-hook 'change-major-mode-hook 'linum-delete-overlays t)
!     (linum-delete-overlays)))
  
  ;;;###autoload
  (define-globalized-minor-mode global-linum-mode linum-mode linum-on)
***************
*** 180,190 ****
    (run-with-idle-timer 0 nil #'linum-update-current))
  
  (defun linum-after-config ()
!   (walk-windows (lambda (w)
!                   (with-current-buffer (window-buffer w)
!                     (when linum-mode
!                       (save-excursion
!                         (linum-update-window w))))) nil 'visible))
  
  (provide 'linum)
  ;;; linum.el ends here
--- 178,184 ----
    (run-with-idle-timer 0 nil #'linum-update-current))
  
  (defun linum-after-config ()
!   (walk-windows (lambda (w) (linum-update (window-buffer))) nil 'visible))
  
  (provide 'linum)
  ;;; linum.el ends here

[-- Attachment #4: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

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

* Re: Redisplay bug in margin
  2007-09-23 22:49           ` Stephen Berman
@ 2007-09-24 18:19             ` Richard Stallman
  2007-09-25 19:52               ` Stephen Berman
  0 siblings, 1 reply; 12+ messages in thread
From: Richard Stallman @ 2007-09-24 18:19 UTC (permalink / raw)
  To: emacs-devel; +Cc: Stephen Berman

Now that Stephen has given us a precise test case,
would someone please fix this bug and ack?

To: emacs-devel@gnu.org
From: Stephen Berman <Stephen.Berman@gmx.net>
Date: Mon, 24 Sep 2007 00:49:44 +0200
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
Subject: Re: Redisplay bug in margin

--=-=-=

On Sun, 23 Sep 2007 17:54:35 -0400 Richard Stallman <rms@gnu.org> wrote:

>     (load-file "<path/to/linum.el>") ;; linum.el version 0.9t
>
> That's not complete.  Could you post it again with a copy
> of the requisite linum.el code?

Sorry, I had misread "including a copy of a version of linum that
causes the failure" as requesting just the version number.  I attach
linum.el version 0.9t to this message; but again, note that the latest
version, 0.9u+ does not show the bug with Emacs 22.1 (though both
versions 0.9t and 0.9u+ show it with CVS Emacs from the trunk).  For
comparison, I also attach a diff between versions 0.9t and 0.9u+.  And
for completeness, here's the recipe again:

1. Save the following lines to  ~/linum-test.el:

(load-file "<path/to/linum.el>") ;; linum.el version 0.9t
(setq linum-format
      (lambda (line)
	(propertize (format "%d" line) 'face 'linum)))
(setq confirm-kill-emacs 'y-or-n-p)

2. emacs -q -l ~/linum-test.el ;; Emacs 22.1

3. M-x display-splash-screen

4. M-x linum-mode

5. C-x C-c

Steve Berman


--=-=-=
Content-Type: text/x-emacs-lisp
Content-Disposition: attachment; filename=linum.el
Content-Description: linum.el version 0.9t

;;; linum.el --- Display line numbers to the left of buffers

;; Copyright (C) 2007  Markus Triska

;; Author: Markus Triska <markus.triska@gmx.at>
;; Keywords: convenience

;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.

;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.

;;; Commentary:

;; Display line numbers for the current buffer. Copy linum.el to your
;; load-path and add to your .emacs:

;;    (require 'linum)

;; Then toggle display of line numbers with M-x linum-mode.

;;; Code:

(defconst linum-version "0.9t")

(defvar linum-overlays nil "Overlays used in this buffer.")
(defvar linum-available nil "Overlays available for reuse.")
(defvar linum-before-numbering nil
  "Functions run in each buffer before line numbering starts.")

(mapc #'make-variable-buffer-local '(linum-overlays linum-available))

(defgroup linum nil
  "Show line numbers to the left of buffers"
  :group 'convenience)

;;;###autoload
(defcustom linum-format 'dynamic
  "Format used to display line numbers. Either a format string
like \"%7d\", 'dynamic to adapt the width as needed, or a
function that is called with a line number as its argument and
should evaluate to a string to be shown on that line. See also
`linum-before-numbering'."
  :group 'linum
  :type 'sexp)

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

(defcustom linum-eager t
  "Whether line numbers should be updated after each command.
The conservative setting `nil' might miss some buffer changes,
and you have to scroll or press C-l to update the numbers."
  :group 'linum
  :type 'boolean)

(defcustom linum-delay t
  "Whether updates should be delayed to give Emacs a chance for
other changes."
  :group 'linum
  :type 'boolean)

;;;###autoload
(define-minor-mode linum-mode
  "Toggle display of line numbers in the left marginal area."
  :lighter ""                           ; for desktop.el
  (if linum-mode
      (progn
        (if linum-eager
            (add-hook 'post-command-hook (if linum-delay
                                             'linum-schedule
                                           'linum-update-current) nil t)
          (add-hook 'after-change-functions 'linum-after-change nil t))
        (add-hook 'window-scroll-functions 'linum-after-scroll nil t)
        (add-hook 'window-size-change-functions 'linum-after-size)
        (add-hook 'change-major-mode-hook 'linum-delete-overlays nil t)
        (add-hook 'window-configuration-change-hook
                  'linum-after-config nil t)
        (linum-update-current)
        (message "Linum mode enabled"))
    (remove-hook 'post-command-hook 'linum-update-current t)
    (remove-hook 'post-command-hook 'linum-schedule t)
    (remove-hook 'window-size-change-functions 'linum-after-size)
    (remove-hook 'window-scroll-functions 'linum-after-scroll t)
    (remove-hook 'after-change-functions 'linum-after-change t)
    (remove-hook 'window-configuration-change-hook 'linum-after-config t)
    (remove-hook 'change-major-mode-hook 'linum-delete-overlays t)
    (linum-delete-overlays)
    (message "Linum mode disabled")))

;;;###autoload
(define-globalized-minor-mode global-linum-mode linum-mode linum-on)

(defun linum-on ()
  (unless (minibufferp)
    (linum-mode 1)))

(defun linum-delete-overlays ()
  "Delete all overlays displaying line numbers for this buffer."
  (mapc #'delete-overlay linum-overlays)
  (setq linum-overlays nil)
  (dolist (w (get-buffer-window-list (current-buffer) nil t))
    (set-window-margins w 0)))

(defun linum-update-current ()
  "Update line numbers for the current buffer."
  (linum-update (current-buffer)))

(defun linum-update (buffer)
  "Update line numbers for all windows displaying BUFFER."
  (with-current-buffer buffer
    (when linum-mode
      (setq linum-available linum-overlays)
      (setq linum-overlays nil)
      (save-excursion
        (mapc #'linum-update-window
              (get-buffer-window-list buffer nil 'visible)))
      (mapc #'delete-overlay linum-available)
      (setq linum-available nil))))

(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 (1+ (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)
        ov)
    (run-hooks 'linum-before-numbering)
    ;; Create an overlay (or reuse an existing one) for each
    ;; line visible in this window.
    (while (and (not (eobp)) (< (point) limit))
      (let ((str (if fmt
                   (propertize (format fmt line) 'face 'linum)
                 (funcall linum-format line))))
        (setq width (max width (length str)))
        (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))
      (forward-line)
      (setq line (1+ line)))
    (set-window-margins win width)))

(defun linum-after-change (beg end len)
  ;; update overlays on deletions, and after newlines are inserted
  (when (or (= beg end)
            (= end (point-max))
            ;; TODO: use string-match-p with CVS or new release
            (string-match "\n" (buffer-substring-no-properties beg end)))
    (linum-update-current)))

(defun linum-after-scroll (win start)
  (linum-update (window-buffer win)))

(defun linum-after-size (frame)
  (linum-after-config))

(defun linum-schedule ()
  ;; schedule an update; the delay gives Emacs a chance for display changes
  (run-with-idle-timer 0 nil #'linum-update-current))

(defun linum-after-config ()
  (walk-windows (lambda (w)
                  (with-current-buffer (window-buffer w)
                    (when linum-mode
                      (save-excursion
                        (linum-update-window w))))) nil 'visible))

(provide 'linum)
;;; linum.el ends here

--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment; filename=linum-09t-09u+.diff
Content-Description: linum-09t-09u+.diff

*** linum.el	2007-09-16 16:29:19.000000000 +0200	version 0.9t
--- linum.el	2007-09-23 14:44:19.000000000 +0200	version 0.9u+
***************
*** 31,37 ****
  
  ;;; Code:
  
! (defconst linum-version "0.9t")
  
  (defvar linum-overlays nil "Overlays used in this buffer.")
  (defvar linum-available nil "Overlays available for reuse.")
--- 31,37 ----
  
  ;;; Code:
  
! (defconst linum-version "0.9u+")
  
  (defvar linum-overlays nil "Overlays used in this buffer.")
  (defvar linum-available nil "Overlays available for reuse.")
***************
*** 88,95 ****
          (add-hook 'change-major-mode-hook 'linum-delete-overlays nil t)
          (add-hook 'window-configuration-change-hook
                    'linum-after-config nil t)
!         (linum-update-current)
!         (message "Linum mode enabled"))
      (remove-hook 'post-command-hook 'linum-update-current t)
      (remove-hook 'post-command-hook 'linum-schedule t)
      (remove-hook 'window-size-change-functions 'linum-after-size)
--- 88,94 ----
          (add-hook 'change-major-mode-hook 'linum-delete-overlays nil t)
          (add-hook 'window-configuration-change-hook
                    'linum-after-config nil t)
!         (linum-update-current))
      (remove-hook 'post-command-hook 'linum-update-current t)
      (remove-hook 'post-command-hook 'linum-schedule t)
      (remove-hook 'window-size-change-functions 'linum-after-size)
***************
*** 97,104 ****
      (remove-hook 'after-change-functions 'linum-after-change t)
      (remove-hook 'window-configuration-change-hook 'linum-after-config t)
      (remove-hook 'change-major-mode-hook 'linum-delete-overlays t)
!     (linum-delete-overlays)
!     (message "Linum mode disabled")))
  
  ;;;###autoload
  (define-globalized-minor-mode global-linum-mode linum-mode linum-on)
--- 96,102 ----
      (remove-hook 'after-change-functions 'linum-after-change t)
      (remove-hook 'window-configuration-change-hook 'linum-after-config t)
      (remove-hook 'change-major-mode-hook 'linum-delete-overlays t)
!     (linum-delete-overlays)))
  
  ;;;###autoload
  (define-globalized-minor-mode global-linum-mode linum-mode linum-on)
***************
*** 180,190 ****
    (run-with-idle-timer 0 nil #'linum-update-current))
  
  (defun linum-after-config ()
!   (walk-windows (lambda (w)
!                   (with-current-buffer (window-buffer w)
!                     (when linum-mode
!                       (save-excursion
!                         (linum-update-window w))))) nil 'visible))
  
  (provide 'linum)
  ;;; linum.el ends here
--- 178,184 ----
    (run-with-idle-timer 0 nil #'linum-update-current))
  
  (defun linum-after-config ()
!   (walk-windows (lambda (w) (linum-update (window-buffer))) nil 'visible))
  
  (provide 'linum)
  ;;; linum.el ends here

--=-=-=
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel
--=-=-=--

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

* Re: Redisplay bug in margin
  2007-09-24 18:19             ` Richard Stallman
@ 2007-09-25 19:52               ` Stephen Berman
  2007-09-26 14:08                 ` Stefan Monnier
  0 siblings, 1 reply; 12+ messages in thread
From: Stephen Berman @ 2007-09-25 19:52 UTC (permalink / raw)
  To: emacs-devel

On Mon, 24 Sep 2007 14:19:49 -0400 Richard Stallman <rms@gnu.org> wrote:

> Now that Stephen has given us a precise test case,
> would someone please fix this bug and ack?
>
> To: emacs-devel@gnu.org
> From: Stephen Berman <Stephen.Berman@gmx.net>
> Date: Mon, 24 Sep 2007 00:49:44 +0200
> Mime-Version: 1.0
> Content-Type: multipart/mixed; boundary="=-=-="
> Subject: Re: Redisplay bug in margin
>
> --=-=-=
>
> On Sun, 23 Sep 2007 17:54:35 -0400 Richard Stallman <rms@gnu.org> wrote:
>
>>     (load-file "<path/to/linum.el>") ;; linum.el version 0.9t
>>
>> That's not complete.  Could you post it again with a copy
>> of the requisite linum.el code?
>
> Sorry, I had misread "including a copy of a version of linum that
> causes the failure" as requesting just the version number.  I attach
> linum.el version 0.9t to this message; but again, note that the latest
> version, 0.9u+ does not show the bug with Emacs 22.1 (though both
> versions 0.9t and 0.9u+ show it with CVS Emacs from the trunk).

Markus Triska has fixed the redisplay bug in the latest version of
linum.el, 0.9v.  This version works for both Emacs 22.1 and CVS Emacs.

Steve Berman

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

* Re: Redisplay bug in margin
  2007-09-25 19:52               ` Stephen Berman
@ 2007-09-26 14:08                 ` Stefan Monnier
  2007-09-26 14:16                   ` Juanma Barranquero
  0 siblings, 1 reply; 12+ messages in thread
From: Stefan Monnier @ 2007-09-26 14:08 UTC (permalink / raw)
  To: Stephen Berman; +Cc: emacs-devel

> Markus Triska has fixed the redisplay bug in the latest version of
> linum.el, 0.9v.  This version works for both Emacs 22.1 and CVS Emacs.

The original impression was that it was a bug in Emacs rather than
in linum.  So does the 0.9v version actually fix the bug (i.e. it really
was in linum.el after all) or does it just work around it?

If it works around it, what workaround does it use?


        Stefan

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

* Re: Redisplay bug in margin
  2007-09-26 14:08                 ` Stefan Monnier
@ 2007-09-26 14:16                   ` Juanma Barranquero
  2007-09-26 14:31                     ` Stephen Berman
  0 siblings, 1 reply; 12+ messages in thread
From: Juanma Barranquero @ 2007-09-26 14:16 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Stephen Berman, emacs-devel

On 9/26/07, Stefan Monnier <monnier@iro.umontreal.ca> wrote:

> The original impression was that it was a bug in Emacs rather than
> in linum.  So does the 0.9v version actually fix the bug (i.e. it really
> was in linum.el after all) or does it just work around it?

It was a bug in linum, which I erroneously took for a redisplay bug.
In some circumstances, linum added the before-string property twice to
some lines. Markus detected the problem and fixed it.

             Juanma

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

* Re: Redisplay bug in margin
  2007-09-26 14:16                   ` Juanma Barranquero
@ 2007-09-26 14:31                     ` Stephen Berman
  0 siblings, 0 replies; 12+ messages in thread
From: Stephen Berman @ 2007-09-26 14:31 UTC (permalink / raw)
  To: emacs-devel

On Wed, 26 Sep 2007 16:16:33 +0200 "Juanma Barranquero" <lekktu@gmail.com> wrote:

> On 9/26/07, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>
>> The original impression was that it was a bug in Emacs rather than
>> in linum.  So does the 0.9v version actually fix the bug (i.e. it really
>> was in linum.el after all) or does it just work around it?
>
> It was a bug in linum, which I erroneously took for a redisplay bug.

Yes, and I reinforced this impression by also referring to it in my
followups as a redisplay bug, sorry.

Steve Berman

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

end of thread, other threads:[~2007-09-26 14:31 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-19 11:16 Redisplay bug in margin Juanma Barranquero
2007-09-20 16:35 ` Richard Stallman
2007-09-20 22:01   ` Stephen Berman
2007-09-23  9:07     ` Richard Stallman
2007-09-23 14:27       ` Stephen Berman
2007-09-23 21:54         ` Richard Stallman
2007-09-23 22:49           ` Stephen Berman
2007-09-24 18:19             ` Richard Stallman
2007-09-25 19:52               ` Stephen Berman
2007-09-26 14:08                 ` Stefan Monnier
2007-09-26 14:16                   ` Juanma Barranquero
2007-09-26 14:31                     ` Stephen Berman

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).