Subject: bug#5042: 23.1; linum-mode gives incorrect line numbers with narrowed buffers

From: Mark Lillibridge <[email-masked]>
Date: Sat, 9 Jan 2010 17:32:18 -0800

Markus wrote:
>  In my opinion, a more general solution than only for linum.el would be
>  best, one that also makes for example line-number-mode show line numbers
>  that work as expected with M-x goto-line RET also for narrowed buffers.
>  Ideally, it should work without having to customize each of these
>  features (and new modes in the future) separately. I think a promising
>  suggestion (found in this thread) is to generalise narrowing itself,
>  possibly with a single new customization option instead of many.

    That's a good idea.  We could add a buffer local variable that
determines how to number lines when a restriction is in effect.  Rmail,
Info, and similar modes could set this variable for their buffers to
start numbering the visible restriction at 1.  Other buffers would
depend on the user's global customization setting.  goto-line, linum,
and related features would consult this variable.

    I don't know any good arguments for which way to set the global
default.

    What do people think of this plan?  The alternative KISS strategy is
to just make line numbering always start with one for restrictions; I
think this makes everybody happy.  The downside is that you can't see
the external line numbers of lines while you have restricted the buffer
and you can't go to lines by their external line number while you have
restricted the buffer.  I, at least, don't use narrow (interactively)
enough that that these drawbacks would matter.

- Mark