I usually use
occur to make an index of the beginning of different things. When I jump to the occurrence,
Occur shows the line in the middle of the buffer. How can I instruct
occur to show the occurrence in the top of the buffer?
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.Sign up to join this community
You can scroll the window in
occur-mode-find-occurrence-hook such that point is at the top of the window:
(defun my-occur-recenter () "Scroll point to the top of the window." (recenter 0)) (add-hook 'occur-mode-find-occurrence-hook #'my-occur-recenter)
occur-mode-find-occurrence-hookare called with point at the position of the selected occurence.
recentercalled with a non-negative argument adjusts the vscroll of the window such that point is located that many lines from the top line.