Subject: bug#9917: bug#5042: bug#9917: bug#5042: bug#9917: 24.0.90; Make `goto-line' consistent with the line number from the minibuffer

From: Drew Adams <[email-masked]>
Date: Thu, 29 Oct 2020 09:44:18 -0700 (PDT)

> >>> So a new command and keystroke seems warranted.  How about...
> >>> `M-g M-v'?   (The mnemonic is "goto visual line".)
> >>
> >> Or to add a new key to narrow-map 'C-x n' where a new key could be:
> >>
> >>   C-x n g         go to narrowed line
> >
> > Perhaps both?  The keystroke makes sense in both contexts -- as a
> > variation on `M-g M-g', and in the group of narrowing keystroke.
> 
> I've added a more localized key binding 'C-x n g',
> but still not sure about the global 'M-g' key bindings.
> Here are some possible variants:
> 
> 1. Bind 'M-g v' to goto-line-relative, while leaving 'M-g g'
>    bound to goto-line that currently uses absolute line numbers
>    (btw, this fact should be mentioned in its docstring);
> 
> 2. Re-bind 'M-g g' to goto-line-relative as many asked to do
>    with the reasoning that 'M-g g' should use by default the
>    same numbering scheme as is displayed by display-line-numbers-mode;
> 
> 3. Leave the existing 'M-g g' bound to goto-line, but allow changing
>    the numbering scheme using a prefix arg and a user option.
>    Or another idea: maybe it should depend on whether
>    display-line-numbers-mode is enabled or not?
>    When display-line-numbers-mode is enabled, then use
>    relative line numbers that are displayed on the left side (WYSIWYG).

FWIW, I think this belongs on `M-g', and not on
`C-x n' (and not on both).

The aim of the command is to go to a line.  IIUC,
it's not a command that is essentially an action on
the buffer restriction (narrowing).

Users will think of this as a goto-line action, and
they will look for it on a key related to going to
a line number.

As others have pointed out, some users won't even
recognize that Info shows a node by narrowing the
overall buffer (the manual).  They won't look for
the key on `C-x n' (and they shouldn't).

Functions that act on relative, instead of absolute,
file names are still basically about file names or
files, and their names and keys generally reflect
that.  Similarly here - this about going to a
relative line number.  Why a user would most likely
want to do that in Info (answer: because it's
narrowed) is secondary, and can almost remain
unremarked.
___

Which brings us back perhaps to _swapping_ relative
and absolute whenever the buffer is narrowed - the
Info case is just a special case of that.

What about doing that (advertising it prominently)?

By default (add an option, to let users choose),
when the buffer is narrowed the regular absolute
goto-line key goes to a relative line number, and
the regular goto-relative line key goes to an
absolute line number.

That would mentally cement the natural relation
between relative line numbering and narrowed buffer.

But by _swapping_ (and certainly not letting one of
the behaviors grab both keys, as was suggested here),
users always have both behaviors available on keys
(including in Info).

Yes, such swapping would be perhaps a first for
Emacs.  But I think it would end up being pretty
natural, even expected.