At first, with functions like
(display-pixel-height), it seems like it should be trivial, but the problem is that Emacs measures its frame height and width in characters, whereas the pixel functions (obviously) work in pixels.
The link comes in the from of
(frame-char-width), which give the height and width of an idividual character in pixels. Just evaluating the following expression should centre Emacs on your primary monitor:
(floor (* 0.95 (/ (display-pixel-height)
(floor (/ (- (display-pixel-width) (frame-pixel-width))
(floor (* 0.02 (display-pixel-height))))
If you like this (maybe after some tweaking), you can just stuff the instructions in your
.emacsto get it every time.