Using the function
describe-key, we can trace
org-agenda-goto, and from there we can examine the function in the
org-agenda.el library to see what makes it tick. The re-centering command is hard-coded as
(recenter (/ (window-height) 2)), which means it cannot be easily controlled by the user with an optional argument or by customizing a variable. In general, functions an be redefined by
require-ing the library followed by the newly defined function with the same name:
(require 'org-agenda) (defun org-agenda-goto (&optional highlight) "Go to the Org-mode file which contains the item at point." ...) Change the portion relating to recentering. The doc-string for
recenter describes the available methods of controling the behavior of said function.
During the process of inspecting
org-agenda-goto, we learned that
org-agenda-after-show-hook is called at the tail-end. A less efficient alternative approach to modifying
org-agenda-goto would be to add new behavior to the aforementioned hook -- however, that would essentially call again
recenter to fix the undesired previous call.