Subject: Re: bug#46119: 28.0.50; this-error-recenter

From: Juri Linkov <[email-masked]>
Date: Tue, 02 Feb 2021 19:05:10 +0200

> I am posting now the approach using two new commands:
>
>     * lisp/window.el (recenter-other-window): New command.
>     Bind recenter-other-window to M-C-l.

M-C-l can't be used because M-C-l is already bound to 'reposition-window'.
Only S-M-C-l is free.

>     * lisp/simple.el (this-error-recenter): New command.

Wouldn't a better name be recenter-current-error
since existing name is compilation-current-error?

> +(defun this-error-recenter (&optional arg)
> +  "Recenter the current displayed error in the `next-error' buffer."
> +  (interactive "P")
> +  (if (not (or (eq major-mode 'occur-mode) (derived-mode-p 'compilation-mode)))
> +      (user-error "This command is for *Occur* or *Grep* buffers")

This is bad restriction that needs to be removed.

> +    (funcall next-error-function 0 nil)
> +    (recenter-top-bottom arg)
> +    (pop-to-buffer next-error-last-buffer)))

`(pop-to-buffer next-error-last-buffer)' has problems
and should be replaced with `save-selected-window'.

Please see the commit 072b4c679dfd5528e74849cad18246730a991933
and bug#32607 for explanations.