[net.emacs] line number display

rms@mit-prep (10/17/85)

From: Richard M. Stallman <rms@mit-prep>
The way the buffer is stored, it is not easy to do this.
The only way to tell what line number anything is
is to count all the newlines.  To make this work fast enough,
it would have to remember the line number of the first
line from the previous redisplay and detect the usual
case in which the text above the window start has not
changed since then.  Most of the mechanism for this
exists already.

I don't think I will write this; I think M-x what-line
is good enough for finding a line number, and I think
it is more important to keep the size of Emacs down.

Sadly, the extensibility of Emacs doesn't help here, because it is
inside of redisplay, which has to be all in C to be fast enough.

chris@umcp-cs.UUCP (Chris Torek) (10/18/85)

In article <110@mit-eddie.UUCP> Richard M. Stallman <rms@mit-prep> writes:

> The way the buffer is stored, it is not easy to do this.  The only
> way to tell what line number anything is is to count all the
> newlines.  To make this work fast enough, it would have to remember
> the line number of the first line from the previous redisplay and
> detect the usual case in which the text above the window start has
> not changed since then.  Most of the mechanism for this exists
> already.

I wrote line number display code for Gosling Emacs once (and it
still exists in our local Emacs); the mechanism proposed above is
exactly the one I used.  It works passably well for small buffers,
but bogs down terribly over about 20K of text.  This could conceivably
be alleviated by creating a linked list of markers---these are the
objects that can tell when text above them has been changed, with
the addition of a few lines of code in buffer.c---and line numbers,
with the new markers being sprinkled throughout the buffer at every
K lines, K being a #define constant which has yet to be determined
based on time vs. space tradeoffs.

However, I have observed very little use of my line number display
facility, so there is no incentive for me to work on it.  When I
use line numbers in vi it is almost invariably to find compiler
errors, and the compile-it facility in Emacs does this better
anyway.

> I don't think I will write this; I think M-x what-line is good
> enough for finding a line number, and I think it is more important
> to keep the size of Emacs down.

?!

	% size /usr/local/bin/gnumacs
	text	data	bss	dec	hex
	379904	163840	0	543744	84c00
	%

I dare say no one would notice the difference.  Yet your first
reason is after all reason enough, I think.  Consider well why you
think you need line numbers:  there is probably a better solution,
well within the present capabilites of Gnu Emacs.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251)
UUCP:	seismo!umcp-cs!chris
CSNet:	chris@umcp-cs		ARPA:	chris@mimsy.umd.edu