Using the function describe-key
, we can trace org-agenda-goto-mouse
to 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.
org-agenda-goto
, since it does not use a variable or argument to control recentering -- instead, it uses(recenter (/ (window-height) 2))
If we describe the middle-mouse-click withdescribe-key
, we see that it triggersorg-agenda-goto-mouse
If we look at that function, we see that it usesorg-agenda-goto
, and if we look at that function, we see a modification of said function would be required based on the foregoing line of code dealing with recentering.(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. Or, if you are an anti-modification believer in the holy scriptureorg-mode
source code, you can use theorg-agenda-after-show-hook
to recenter again using whatever you like -- note that this is technically inefficient considering that recentering could have been customized by modifyingorg-agenda-goto
.org-agenda-goto
worked like a charm. Want to post that as an answer?