Skip to content

Instantly share code, notes, and snippets.

@jgarvin
Created June 23, 2024 00:36
Show Gist options
  • Save jgarvin/ae7e58939e75c0d52153e71b42646968 to your computer and use it in GitHub Desktop.
Save jgarvin/ae7e58939e75c0d52153e71b42646968 to your computer and use it in GitHub Desktop.
(defun etc-maybe-recenter ()
(unless (or
;; don't interfere with erc scroll-to-bottom
(derived-mode-p 'erc-mode 'term-mode 'shell-mode 'eshell-mode)
(not (eq (get-buffer-window (current-buffer) t) (selected-window)))
(equal (window-point) (point-max))
(region-active-p)
)
(recenter)))
(defvar etc-recenter-timer nil)
(progn
(when etc-recenter-timer
(cancel-timer etc-recenter-timer))
(setq etc-recenter-timer nil)
(setq etc-recenter-timer (run-with-idle-timer 0.25 t #'etc-maybe-recenter)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment