GNU bug report logs - #37856
27.0.50; 'next-error' advised with 'recenter' signals error when run from "*grep*" buffer

Previous Next

Package: emacs;

Reported by: Stefan Kangas <stefan <at> marxist.se>

Date: Mon, 21 Oct 2019 18:40:02 UTC

Severity: normal

Found in version 27.0.50

Done: Stefan Kangas <stefan <at> marxist.se>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Kangas <stefan <at> marxist.se>
Cc: 37856 <at> debbugs.gnu.org
Subject: bug#37856: 27.0.50; 'next-error' advised with 'recenter' signals error when run from "*grep*" buffer
Date: Mon, 21 Oct 2019 22:30:42 +0300
> From: Stefan Kangas <stefan <at> marxist.se>
> Date: Mon, 21 Oct 2019 20:38:47 +0200
> 
> 1. Under "emacs -Q", evaluate:
>     (defun my-advice (&rest args)
>       (recenter))
>     (advice-add 'next-error :after #'my-advice)
> 2. M-x rgrep RET [... grep for something]
> 3. Run 'next-error' (M-g M-n) from the "*grep*" buffer.
> 
> Result: I get the error:
>     recenter-top-bottom: ‘recenter’ing a window that does not display
> current-buffer.

Why isn't this a cockpit error: you force a function that happens to
switch buffers to recenter.  It's like you've added a call to
'recenter' in some arbitrary place in a random function: you are
responsible for that code, and if it does stuff that it shouldn't,
your code is wrong.  No?

> This seems to be due to this code in window.c:
> 
>   /* For reasons why we signal an error here, see
>      https://lists.gnu.org/r/emacs-devel/2014-06/msg00053.html,
>      https://lists.gnu.org/r/emacs-devel/2014-06/msg00094.html.  */
>   if (buf != current_buffer)
>     error ("`recenter'ing a window that does not display current-buffer.");

Yes, and that's on purpose, see the cited discussion.




This bug report was last modified 5 years and 215 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.