I always want to run reposition-window
after c-beginning-of-defun
.
I've tried this:
(advice-add 'c-beginning-of-defun :after #'reposition-window)
it results in this at execution:
Variable binding depth exceeds max-specpdl-size
I've considered hooks, but I don't know how to find a hook for c-beginning-of-defun
. I don't think hooks are the way to go if it's not for modes.
I've tried redefining c-beginning-of-defun
, but then I need to call to the previous version, and I get infinite recursion.
I've tried implementing my own function:
(defun my-beginning-of-defun ()
(interactive)
(beginning-of-defun)
(reposition-window))
(global-set-key (kbd "C-M-a") 'my-beginning-of-defun) ;;; This doesn't bite!
but this doesn't work in C, because its major mode overrides C-M-a
with the C version of the function. I could make my own version of the C function as well, and bind C-M-a
in my own c-mode-hook, but... It seems like doing work that advises are designed to do.