Advising an emacs function; defadvice

409 Views Asked by At

I'm trying to advise a function in emacs, but nothing happens.

(defadvice save-place-find-file-hook (after recenter activate)
  "Recenter after getting to saved place."
  (recenter))

Recentering doesn't happen, that is. If have a (message "foo") instead, foo is indeed displayed. What is it that I don't know about defadvice?

1

There are 1 best solutions below

4
Stefan On

find-file-hook is run before the buffer is displayed, so your recentering does not apply to the buffer you think it does and is undone immediately after it happened, when find-file replaces the current buffer with the new buffer in the selected window.