From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#11496: 24.1.50; Line numbers are not redrawn correctly in linum-mode Date: Wed, 16 May 2012 22:40:39 -0400 Message-ID: References: <86likr37id.fsf@googlemail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1337222518 14260 80.91.229.3 (17 May 2012 02:41:58 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 17 May 2012 02:41:58 +0000 (UTC) Cc: 11496@debbugs.gnu.org To: Christoph Scholtes Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu May 17 04:41:57 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SUqf5-0008IZ-IC for geb-bug-gnu-emacs@m.gmane.org; Thu, 17 May 2012 04:41:55 +0200 Original-Received: from localhost ([::1]:56589 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SUqf4-0002eU-Ty for geb-bug-gnu-emacs@m.gmane.org; Wed, 16 May 2012 22:41:54 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:50288) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SUqf2-0002eI-4X for bug-gnu-emacs@gnu.org; Wed, 16 May 2012 22:41:53 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SUqf0-0002k1-7V for bug-gnu-emacs@gnu.org; Wed, 16 May 2012 22:41:51 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:48817) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SUqf0-0002jw-4L for bug-gnu-emacs@gnu.org; Wed, 16 May 2012 22:41:50 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1SUqfC-0005qo-4w for bug-gnu-emacs@gnu.org; Wed, 16 May 2012 22:42:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 17 May 2012 02:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 11496 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 11496-submit@debbugs.gnu.org id=B11496.133722246222411 (code B ref 11496); Thu, 17 May 2012 02:42:02 +0000 Original-Received: (at 11496) by debbugs.gnu.org; 17 May 2012 02:41:02 +0000 Original-Received: from localhost ([127.0.0.1]:58363 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SUqeC-0005pL-TE for submit@debbugs.gnu.org; Wed, 16 May 2012 22:41:01 -0400 Original-Received: from ironport-out.teksavvy.com ([206.248.143.162]:18515) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SUqeA-0005p7-UJ for 11496@debbugs.gnu.org; Wed, 16 May 2012 22:40:59 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjIKACxOgk9FpZcD/2dsb2JhbABDtheCDAOBDIEIggkBAQQBViMFCwsOJhIUGA0kiBwFtjKLYYR5BI5slVmBXYMD X-IronPort-AV: E=Sophos;i="4.75,391,1330923600"; d="el'?scan'208";a="180649028" Original-Received: from 69-165-151-3.dsl.teksavvy.com (HELO pastel.home) ([69.165.151.3]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 16 May 2012 22:40:40 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 378515979C; Wed, 16 May 2012 22:40:39 -0400 (EDT) In-Reply-To: <86likr37id.fsf@googlemail.com> (Christoph Scholtes's message of "Wed, 16 May 2012 19:45:30 -0600") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:60102 Archived-At: --=-=-= Content-Type: text/plain > Start with emacs -Q. > Don't maximize frame. > Open a file that has more lines than the current frame. > M-x linum-mode > Maximize frame. > Line numbers are only drawn where the original, visible frame boundary > was. > Press down arrow key. > Line numbers are redrawn for the entire frame. > The same thing happens when narrowing on a function and then widen > again. Only the narrowed piece has the new line numbers until the next > explicit redraw. You may have more luck with my reimplementation of linum which uses jit-lock, which hopefully fixes those problems (tho it may come with others of course). Stefan --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=nlinum.el Content-Transfer-Encoding: quoted-printable ;;; nlinum.el --- Show line numbers in the margin -*- lexical-binding: t -= *- ;; Copyright (C) 2012 Free Software Foundation, Inc. ;; Author: Stefan Monnier ;; Keywords: convenience ;; Version: 0.1 ;; This program 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 of the License, or ;; (at your option) any later version. ;; This program 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 this program. If not, see . ;;; Commentary: ;; This is like linum-mode, but uses jit-lock. ;;; Code: (eval-when-compile (require 'cl)) (require 'linum) ;For its face. (defvar nlinum--width 2) (make-variable-buffer-local 'nlinum--width) ;; (defvar nlinum--desc "") ;;;###autoload (define-minor-mode nlinum-mode "Toggle display of line numbers in the left margin (Linum mode). With a prefix argument ARG, enable Linum mode if ARG is positive, and disable it otherwise. If called from Lisp, enable the mode if ARG is omitted or nil. Linum mode is a buffer-local minor mode." :lighter nil ;; (" NLinum" nlinum--desc) (jit-lock-unregister #'nlinum--region) (remove-hook 'window-configuration-change-hook #'nlinum--setup-window t) (remove-overlays (point-min) (point-max) 'nlinum t) (kill-local-variable 'nlinum--width) (when nlinum-mode (add-hook 'window-configuration-change-hook #'nlinum--setup-window nil = t) (jit-lock-register #'nlinum--region t)) (nlinum--setup-windows)) (defun nlinum--setup-window () (set-window-margins nil (if nlinum-mode nlinum--width) (cdr (window-margins)))) (defun nlinum--setup-windows () (dolist (win (get-buffer-window-list nil nil t)) (with-selected-window win (nlinum--setup-window)))) (defun nlinum--new-width () (nlinum--setup-windows) (remove-overlays (point-min) (point-max) 'nlinum t) (run-with-timer 0 nil (lambda (buf) (with-current-buffer buf (with-silent-modifications (remove-text-properties (point-min) (point-max) '(fontified))))) (current-buffer))) (defun nlinum--ol-count () (let ((i 0)) (dolist (ol (overlays-in (point-min) (point-max))) (when (overlay-get ol 'nlinum) (incf i))) i)) (defun nlinum--region (start limit) (save-excursion ;; Text may contain those nasty intangible properties, but ;; that shouldn't prevent us from counting those lines. (let ((inhibit-point-motion-hooks t)) (goto-char start) (unless (bolp) (forward-line 1)) (remove-overlays (point) limit 'nlinum t) (let ((line (line-number-at-pos)) (fmt (format "%%%dd" nlinum--width))) (while (and (not (eobp)) (< (point) limit) (let* ((ol (make-overlay (point) (1+ (point)))) (str (format fmt line)) (width (string-width str))) (when (< nlinum--width width) (setq nlinum--width width) (nlinum--new-width)) (overlay-put ol 'nlinum t) (overlay-put ol 'evaporate t) (overlay-put ol 'before-string (propertize " " 'display `((margin left-margin) ,(propertize str 'face 'linum)))) (setq line (1+ line)) (zerop (forward-line 1)))))))) nil) =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 =20=20=20=20=20=20=20=20 (provide 'nlinum) ;;; nlinum.el ends here --=-=-=--