From unknown Fri Jun 20 07:09:34 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#4996 <4996@debbugs.gnu.org> To: bug#4996 <4996@debbugs.gnu.org> Subject: Status: 23.1; linum mode fails to number lines properly when just scrolling buffer Reply-To: bug#4996 <4996@debbugs.gnu.org> Date: Fri, 20 Jun 2025 14:09:34 +0000 retitle 4996 23.1; linum mode fails to number lines properly when just sc= rolling buffer reassign 4996 emacs submitter 4996 mark.lillibridge@hp.com severity 4996 normal thanks From mark.lillibridge@hp.com Fri Nov 20 21:31:08 2009 Received: (at submit) by emacsbugs.donarmstrong.com; 21 Nov 2009 05:31:08 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-0.5 required=4.0 tests=AWL autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nAL5V7hI004706 for ; Fri, 20 Nov 2009 21:31:08 -0800 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NBiYs-0000Eb-S8 for bug-gnu-emacs@gnu.org; Sat, 21 Nov 2009 00:31:06 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NBiYn-0000C3-HN for bug-gnu-emacs@gnu.org; Sat, 21 Nov 2009 00:31:05 -0500 Received: from [199.232.76.173] (port=58564 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NBiYn-0000C0-Ad for bug-gnu-emacs@gnu.org; Sat, 21 Nov 2009 00:31:01 -0500 Received: from madara.hpl.hp.com ([192.6.19.124]:53966) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NBiYm-0003xA-6L for bug-gnu-emacs@gnu.org; Sat, 21 Nov 2009 00:31:00 -0500 Received: from mailhub-pa1.hpl.hp.com (mailhub-pa1.hpl.hp.com [15.25.115.25]) by madara.hpl.hp.com (8.14.3/8.14.1/HPL-PA Relay) with ESMTP id nAL5UmZH010617 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Fri, 20 Nov 2009 21:30:48 -0800 (PST) Received: from ts-rhel4.hpl.hp.com (ts-rhel4.hpl.hp.com [15.25.118.24]) by mailhub-pa1.hpl.hp.com (8.14.3/8.14.3/HPL-PA Hub) with ESMTP id nAL5UkcT017095; Fri, 20 Nov 2009 21:30:46 -0800 Date: Fri, 20 Nov 2009 21:30:46 -0800 Message-Id: <200911210530.nAL5UkcT017095@mailhub-pa1.hpl.hp.com> From: Mark Lillibridge To: bug-gnu-emacs@gnu.org Subject: 23.1; linum mode fails to number lines properly when just scrolling buffer Reply-to: mark.lillibridge@hp.com X-HPL-MailScanner: Found to be clean X-HPL-MailScanner-From: mark.lillibridge@hp.com X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Please write in English if possible, because the Emacs maintainers usually do not have translators to read other languages for them. Your bug report will be posted to the bug-gnu-emacs@gnu.org mailing list, and to the gnu.emacs.bug news group. Please describe exactly what actions triggered the bug and the precise symptoms of the bug: In emacs, invoke report-emacs-bug :-) while global-linum-mode is on. Observe that there is some kind of overlay that occupies 9 lines before this point. That is, the spot where this paragraph starts is labeled line 7. Now page down (^v) and back (esc v). Observe that now every display line, including inside the overlay, has a line number. *BUG* What was line 7 is now shown as line 17. As soon as you do another command like a right arrow, the line numbers revert to the original correct line numbering. Linum has a hook for window-scroll-functions: linum.el:74: (define-minor-mode linum-mode "Toggle display of line numbers in the left margin." :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 nil t) (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)) linum.el:175: (defun linum-after-scroll (win start) (linum-update (window-buffer win))) If I disable this function by doing (via {esc}:): (defun linum-after-scroll (win start) t) the bug goes away. I am investigating further, but the problem appears to be that forward-line acts differently during window-scroll-functions hook then normally. Some sort of dynamic variable binding, perhaps? - Mark From mark.lillibridge@hp.com Fri Nov 20 22:06:59 2009 Received: (at 4996) by emacsbugs.donarmstrong.com; 21 Nov 2009 06:07:00 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-0.4 required=4.0 tests=AWL,MURPHY_DRUGS_REL8 autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 Received: from madara.hpl.hp.com (madara.hpl.hp.com [192.6.19.124]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nAL66vG5008592 for <4996@emacsbugs.donarmstrong.com>; Fri, 20 Nov 2009 22:06:59 -0800 Received: from mailhub-pa1.hpl.hp.com (mailhub-pa1.hpl.hp.com [15.25.115.25]) by madara.hpl.hp.com (8.14.3/8.14.1/HPL-PA Relay) with ESMTP id nAL66mNV013242 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for <4996@emacsbugs.donarmstrong.com>; Fri, 20 Nov 2009 22:06:49 -0800 (PST) Received: from ts-rhel4.hpl.hp.com (ts-rhel4.hpl.hp.com [15.25.118.24]) by mailhub-pa1.hpl.hp.com (8.14.3/8.14.3/HPL-PA Hub) with ESMTP id nAL66k3Z017990; Fri, 20 Nov 2009 22:06:47 -0800 Date: Fri, 20 Nov 2009 22:06:46 -0800 Message-Id: <200911210606.nAL66k3Z017990@mailhub-pa1.hpl.hp.com> From: Mark Lillibridge To: 4996@debbugs.gnu.org Subject: problem found Reply-to: mark.lillibridge@hp.com X-HPL-MailScanner: Found to be clean X-HPL-MailScanner-From: mark.lillibridge@hp.com Ah! I have figured out the problem. report-emacs-bug adds the intangible property to the instructions. Normally, forward-line skips past text with the intangible property and this is what happens when linum-update is called normally, hence those lines do not receive line numbers normally. [UPDATE: this is a different bug in linum as it normally reports incorrect line numbers in the presence of intangible text; ironically, the case I was reporting is one of the few when it reports the *correct* line numbers. Consider this a bug report for the behavior of the window-scroll-functions callers.] However, for some reason inhibit-point-motion-hooks is set to t when the window-scroll-functions hooks are called. This causes linum-update, which uses forward-line, to number the intangible lines only when called from the scrolling hook. The following code change, which fixes the bug, demonstrates this: [UPDATE: this actually breaks linum further] (defun linum-after-scroll (win start) (let ((old inhibit-point-motion-hooks)) (setq inhibit-point-motion-hooks nil) (linum-update (window-buffer win)) (setq inhibit-point-motion-hooks old))) I am not sure if the actual bug here is with the callers of window-scroll-functions incorrectly setting inhibit-point-motion-hooks or with linum-after-scroll (in which case, the documentation for window-scroll-functions should mention this behavior). If the later, a better patch should be used that uses unwind-protect or the like. - Mark From mark.lillibridge@hp.com Fri Nov 20 22:24:28 2009 Received: (at 4996) by emacsbugs.donarmstrong.com; 21 Nov 2009 06:24:28 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-0.4 required=4.0 tests=AWL,MURPHY_DRUGS_REL8 autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 Received: from madara.hpl.hp.com (madara.hpl.hp.com [192.6.19.124]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nAL6OQVY010307 for <4996@emacsbugs.donarmstrong.com>; Fri, 20 Nov 2009 22:24:28 -0800 Received: from mailhub-pa1.hpl.hp.com (mailhub-pa1.hpl.hp.com [15.25.115.25]) by madara.hpl.hp.com (8.14.3/8.14.1/HPL-PA Relay) with ESMTP id nAL6OIC6014183 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for <4996@emacsbugs.donarmstrong.com>; Fri, 20 Nov 2009 22:24:18 -0800 (PST) Received: from ts-rhel4.hpl.hp.com (ts-rhel4.hpl.hp.com [15.25.118.24]) by mailhub-pa1.hpl.hp.com (8.14.3/8.14.3/HPL-PA Hub) with ESMTP id nAL6OHvw018404; Fri, 20 Nov 2009 22:24:17 -0800 Date: Fri, 20 Nov 2009 22:24:17 -0800 Message-Id: <200911210624.nAL6OHvw018404@mailhub-pa1.hpl.hp.com> From: Mark Lillibridge To: mark.lillibridge@hp.com CC: 4996@debbugs.gnu.org In-reply-to: <200911210606.nAL66k3Z017990@mailhub-pa1.hpl.hp.com> (message from Mark Lillibridge on Fri, 20 Nov 2009 22:06:46 -0800) Subject: Re: problem found Reply-to: mark.lillibridge@hp.com References: <200911210606.nAL66k3Z017990@mailhub-pa1.hpl.hp.com> X-HPL-MailScanner: Found to be clean X-HPL-MailScanner-From: mark.lillibridge@hp.com Ok, I have a proposed patch for linum.el that solves the problem with it displaying incorrect line numbers in the presence of intangible text. The original version of linum.el has: linum.el:129: (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)))) (forward-line) (setq line (1+ line))) (set-window-margins win width))) The problem here is the third to last line, linum.el:164: (forward-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) (forward-line) (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. Comments? - Mark From news@novembaer.univie.ac.at Sat Nov 21 00:25:21 2009 Received: (at submit) by emacsbugs.donarmstrong.com; 21 Nov 2009 08:25:22 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-5.6 required=4.0 tests=AWL,HAS_BUG_NUMBER autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nAL8PJYH023083 for ; Sat, 21 Nov 2009 00:25:21 -0800 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NBlHS-00058p-N3 for bug-gnu-emacs@gnu.org; Sat, 21 Nov 2009 03:25:18 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NBlHP-00055U-2N for bug-gnu-emacs@gnu.org; Sat, 21 Nov 2009 03:25:18 -0500 Received: from [199.232.76.173] (port=59121 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NBlHO-00055L-Oi for bug-gnu-emacs@gnu.org; Sat, 21 Nov 2009 03:25:14 -0500 Received: from mx20.gnu.org ([199.232.41.8]:5892) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NBlHO-00029A-Jm for bug-gnu-emacs@gnu.org; Sat, 21 Nov 2009 03:25:14 -0500 Received: from moderators.individual.net ([130.133.4.7]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NBlHN-0004K0-Jd for bug-gnu-emacs@gnu.org; Sat, 21 Nov 2009 03:25:13 -0500 Received: from novembaer.univie.ac.at ([193.171.255.22]) by moderators.individual.net (Exim 4.69) for gnu-emacs-bug@moderators.isc.org with esmtp (envelope-from ) id <1NBlHM-0007aA-Lk>; Sat, 21 Nov 2009 09:25:12 +0100 Received: from news by novembaer.univie.ac.at with local (Exim 4.20) id 1NBlHK-000ItM-No for gnu-emacs-bug@moderators.isc.org; Sat, 21 Nov 2009 09:25:10 +0100 To: gnu-emacs-bug@moderators.isc.org From: Markus Triska Newsgroups: gnu.emacs.bug Subject: Re: bug#4996: problem found References: <200911210606.nAL66k3Z017990@mailhub-pa1.hpl.hp.com> Date: Sat, 21 Nov 2009 09:25:11 +0100 Message-ID: Cancel-Lock: sha1:4yECFgCxfUFjrj354U6yXUKhIYs= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Lines: 13 NNTP-Posting-Host: news-access-from.tuwien.ac.at X-Trace: 1258791910 tunews.univie.ac.at 11868 192.35.241.118 X-Complaints-To: abuse@tuwien.ac.at Sender: X-detected-operating-system: by mx20.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Mark Lillibridge writes: > I propose changing that line to: > > (let ((old-inhibit inhibit-point-motion-hooks)) > (setq inhibit-point-motion-hooks t) > (forward-line) > (setq inhibit-point-motion-hooks old-inhibit)) I suggest: (let ((inhibit-point-motion-hooks t)) (forward-line)) From monnier@faina.iro.umontreal.ca Tue Nov 24 14:28:30 2009 Received: (at 4996-done) by emacsbugs.donarmstrong.com; 24 Nov 2009 22:28:30 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-3.9 required=4.0 tests=AWL,HAS_BUG_NUMBER autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 Received: from chene.dit.umontreal.ca (chene.dit.umontreal.ca [132.204.246.20]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nAOMSSOD030795 for <4996-done@emacsbugs.donarmstrong.com>; Tue, 24 Nov 2009 14:28:29 -0800 Received: from faina.iro.umontreal.ca (faina.iro.umontreal.ca [132.204.26.177]) by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id nAOMSRH8017022; Tue, 24 Nov 2009 17:28:27 -0500 Received: by faina.iro.umontreal.ca (Postfix, from userid 20848) id 404E23A1B6; Tue, 24 Nov 2009 17:28:27 -0500 (EST) From: Stefan Monnier To: Markus Triska Subject: Re: bug#4996: problem found Message-ID: References: <200911210606.nAL66k3Z017990@mailhub-pa1.hpl.hp.com> Date: Tue, 24 Nov 2009 17:28:27 -0500 In-Reply-To: (Markus Triska's message of "Sat, 21 Nov 2009 09:25:11 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV3413=0 >> I propose changing that line to: >> >> (let ((old-inhibit inhibit-point-motion-hooks)) >> (setq inhibit-point-motion-hooks t) >> (forward-line) >> (setq inhibit-point-motion-hooks old-inhibit)) > I suggest: > (let ((inhibit-point-motion-hooks t)) > (forward-line)) Thanks, installed, Stefan From unknown Fri Jun 20 07:09:34 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 23 Dec 2009 12:24:03 +0000 User-Agent: Fakemail v42.6.9 # A New Hope # A long time ago, in a galaxy far, far away # something happened. # # Magically this resulted in the following # action being taken, but this fake control # message doesn't tell you why it happened # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator