bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#9917: bug#5042: bug#9917: 24.0.90; Make `goto-line' consistent with


From: Juri Linkov
Subject: bug#9917: bug#5042: bug#9917: 24.0.90; Make `goto-line' consistent with the line number from the minibuffer
Date: Mon, 21 Sep 2020 22:03:44 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

> However, if people have a narrowed buffer, and are looking at (say) the
> compilation output that says "error on like 45" in a shell, then `M-g g
> 45' will definitely do the wrong thing is we change the command to start
> counting from the start of the narrowed region.

In this case another option is to widen the buffer before going to that line.
This is what for example help-function-def--button-function does:

            ;; Widen the buffer if necessary to go to this position.
            (when (or (< position (point-min))
                      (> position (point-max)))
              (widen))
            (goto-char position)

Unfortunately, xref doesn't provide such nice feature,
so 'M-.' fails to navigate in a narrowed buffer.

For 'M-g M-g' this means removing 'save-restriction' from 'goto-line'.

> 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' that currently
contains only 4 keys:

  C-x n d         narrow-to-defun
  C-x n n         narrow-to-region
  C-x n p         narrow-to-page
  C-x n w         widen

where a new key could be:

  C-x n g         go to narrowed line





reply via email to

[Prev in Thread] Current Thread [Next in Thread]