Suppose a third-party plugin contains the following function:
(defun example-function () (interactive) ;; ... do many things ... (goto-char (point-max)) ;; ... do many things ... (goto-char (point-max)) ;; ... do many things ... (goto-char (point-max)))
The function uses
goto-char in various places in its body.
I want to change the behavior of the function such that every time it calls
(goto-char (point-max)), it will also call
(recenter -1). To that end, I added this advice to redefine the calls to
(advice-add 'example-function :around (lambda (orig-fun &rest args) (cl-labels ((goto-char (pos) (goto-char pos) (recenter -1))) (apply orig-fun args))))
cl-labels appears to have no effect;
goto-char still retains its old behavior inside
example-function. What is wrong with the advice?
(Emacs version: GNU Emacs 25.2)