GNU bug report logs - #5042
23.1; linum-mode gives incorrect line numbers with narrowed buffers

Previous Next

Package: emacs;

Reported by: mark.lillibridge <at> hp.com

Date: Thu, 26 Nov 2009 00:45:04 UTC

Severity: wishlist

Merged with 9917, 16173

Found in versions 24.0.90, 24.3.50

Forwarded to http://lists.gnu.org/archive/html/emacs-devel/2010-06/msg00143.html

Full log


Message #23 received at 5042 <at> debbugs.gnu.org (full text, mbox):

From: Mark Lillibridge <mark.lillibridge <at> hp.com>
To: lekktu <at> gmail.com
Cc: 5042 <at> debbugs.gnu.org
Subject: Re: bug#5042: 23.1; linum-mode gives incorrect line numbers with 
	narrowed buffers
Date: Sun, 20 Dec 2009 22:59:43 -0800
Okay, let us see where we stand:

* Juanma uses linum mode to know how many lines there are in a file (or
  a region, if narrowing is in effect) at a glance; they do not use go
  to line.

* Mark (aka, me) and others specify lines to act on by reading off line
  numbers provided by linum and use goto-line to implement voice
  commands; it is crucial for this purpose that the line numbers
  provided correspond to the line numbers goto-line uses in all cases,
  including for non-current buffers.

* linum mode currently does what Juanma wants.

* A somewhat non-obvious and fragile hook function can convert the
  current mode into what Mark wants:

(add-hook 'linum-before-numbering-hook
	   (function (lambda ()
		       (setq line (save-restriction
				    (widen) (line-number-at-pos))))))
  
  (line here is a local variable of the linum-update-window, bound
  shortly before the hook is called; needless to say, this modification
  is unlikely to continue working as the linum code evolves.)

* I think you can build a less fragile hook by using a custom version of
  linum-format, however, this interferes with the ability to use
  linum-format for any other purpose.

* Both modes produce surprises: Juanma's causes surprises when goto-line
  goes to the wrong line in some buffers and Mark's causes surprises
  when some buffers start with a line number greater than one.  Using
  Juanma's mode plus changing the behavior of goto-line would produce no
  obvious surprises, but I cannot be sure that changing goto-line
  does not mess something else up.


    I think that given that Mark's mode is likely to be useful enough of
the time and that implementing it is nontrivial, especially for
beginners, there should be an explicit option to switch between the
modes.  The default should probably depend on which surprise people
think is worse.  I can live with either way.  I am willing to take a
stab at trying to implement such an option if people think this is a
good idea.

- Mark





This bug report was last modified 4 years and 228 days ago.

Previous Next


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