unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#5042: 23.1; linum-mode gives incorrect line numbers with narrowed buffers
@ 2009-11-26  0:39 Mark Lillibridge
  2009-12-01  0:32 ` Juanma Barranquero
  0 siblings, 1 reply; 23+ messages in thread
From: Mark Lillibridge @ 2009-11-26  0:39 UTC (permalink / raw)
  To: bug-gnu-emacs


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:


    Linum-mode does not work correctly with buffers that have been
narrowed.  As a simple example, type ^h i.  You will note that the first
line is assigned line number one.  You can verify that this is wrong
either by using goto-line (watch what happens when you try to go to line
10) or widen, which reveals that the first line is actually line number
five.

The bug is the use by linum of line-number-at-pos,

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))
  ...

<help for line-number-at-pos>:
line-number-at-pos is a compiled Lisp function in `simple.el'.

(line-number-at-pos &optional pos)

Return (narrowed) buffer line number at position pos.
If pos is nil, use current buffer location.
Counting starts at (point-min), so the value refers
to the contents of the accessible portion of the buffer.


A simple fix is to change the line:

linum.el:132:
  (let ((line (line-number-at-pos))

to:

  (let ((line (save-restriction
		(widen)
		(line-number-at-pos)))


- Mark







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

end of thread, other threads:[~2010-02-03  5:01 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-26  0:39 bug#5042: 23.1; linum-mode gives incorrect line numbers with narrowed buffers Mark Lillibridge
2009-12-01  0:32 ` Juanma Barranquero
2009-12-10  5:34   ` Mark Lillibridge
2009-12-10 11:41     ` Juanma Barranquero
2009-12-21  6:59       ` Mark Lillibridge
2009-12-21 10:37         ` Juanma Barranquero
2009-12-21 15:50           ` Drew Adams
2009-12-23 20:49             ` Mark Lillibridge
2009-12-23 21:01               ` Drew Adams
2009-12-23 21:44                 ` Mark Lillibridge
2009-12-24  3:49             ` Stefan Monnier
2009-12-29  7:02               ` Kevin Rodgers
2010-01-07  5:38           ` Mark Lillibridge
2010-01-07 23:30             ` Markus Triska
2010-01-10  1:32               ` Mark Lillibridge
2010-01-10  1:56                 ` Juanma Barranquero
2010-01-16 22:08                   ` Mark Lillibridge
2010-01-16 23:03                     ` Juanma Barranquero
2010-01-23 23:28                       ` Mark Lillibridge
2010-01-24  0:07                         ` Drew Adams
2010-02-03  5:01                           ` Mark Lillibridge
2010-01-24  9:21                         ` Juanma Barranquero
2010-01-10  2:05                 ` Lennart Borgman

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).