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

From: Robert Pluim <[email-masked]>
Date: Tue, 22 Oct 2019 09:56:14 +0200

>>>>> On Tue, 22 Oct 2019 00:19:13 +0200, Stefan Kangas <[email-masked]> said:

    Stefan> Juanma Barranquero <[email-masked]> writes:
    >> > What am I missing?
    >> 
    >> What's wrong with
    >> 
    >> (add-hook 'next-error-hook 'recenter)

    Stefan> Oops, how silly of me.  Yes, I'll just use that.  Thanks.

    Stefan> I'm still a bit confounded by the above behaviour, but if everyone
    Stefan> else feels that everything is in order I'll just go ahead and close
    Stefan> this.  Sorry about the noise.

The add-function docstring says:

    Add a piece of advice on the function stored at PLACE.
    FUNCTION describes the code to add.  WHERE describes where to add it.
    WHERE can be explained by showing the resulting new function, as the
    result of combining FUNCTION and the previous value of PLACE, which we
    call OLDFUN here:
    `:before'	(lambda (&rest r) (apply FUNCTION r) (apply OLDFUN r))
    `:after'	(lambda (&rest r) (prog1 (apply OLDFUN r) (apply FUNCTION r)))
    `:around'	(lambda (&rest r) (apply FUNCTION OLDFUN r))

so I think Iʼd agree with your expectations. Of course, you could use
:around and call 'next-error' yourself in your function (untested).

Robert