When selecting an item from the occur buffer, the highlighted line is at the very bottom of the visible screen. This is less useful than having it 25-50% of the way down the screen(so it's easy to read the text around the found line). Is this possible?
I don't see the behavior that you describe, at all. For me, when I choose an occurrence in buffer
*Occur* it visits the occurrence in the source buffer, putting that smack in the middle of the source-buffer window (vertically).
But if you see what you describe, then just put some window-recentering code on
Something like this. You can use any comparison condition you like. Here, I used "within 10 lines of the top or bottom", but you could use percentages etc.
(defun foo () (let ((line (line-number-at-pos))) (cond ((<= line (+ (line-number-at-pos (window-start)) 10)) (recenter 10)) ((>= line (- (line-number-at-pos (window-end)) 10)) (recenter -10))))) (add-hook 'occur-mode-find-occurrence-hook 'foo)