Here is the best Occur configuration that I’ve ever had on my machine.
- Alternate search result background color
- Multiple Occur buffers
n
andp
navigate search results- Jump near buffer top
(defun help/occur-mode-hook-fn () "HELP customizations." (interactive) (turn-on-stripe-buffer-mode) (occur-rename-buffer)) (add-hook 'occur-mode-hook #'help/occur-mode-hook-fn) (define-key occur-mode-map (kbd "n") #'next-logical-line) (define-key occur-mode-map (kbd "p") #'previous-logical-line) (defun help/recenter-line-near-top-fn () "Move current line near top" (interactive) (let ((recenter-positions '(5))) (recenter-top-bottom))) (add-hook 'occur-mode-find-occurrence-hook #'help/recenter-line-near-top-fn)
Addendum:
stripe-buffer mode provides the buffer striping.
Thank you Greg for reminding me to point that out.
Very nice! It’s worth mentioning this uses the package `stripe-buffer`.
Thank you for the reminder Greg and have a great day.