Displaying the source line in the middle of the window is the default behaviour, so something in your own config has caused your problem.
The variable C-hv next-error-recenter
usually determines where the line is positioned. A value of -1
will place it at the bottom of the window (which may be the cause of your problem); a value of 0
at the top; nil
means "if the line is already visible somewhere in the window simply move point to there, but otherwise display the line in the centre of the window".
If you want to centre the line even when the line was already visible, you can use a value of '(4)
(which mimics passing a prefix argument C-u to recenter
), but I think you'll find the nil
behaviour less disorientating.
Failing anything else (or if the above is not the cause of your problem), have a look at C-hv next-error-hook
in case something is using that.