Created
October 16, 2017 15:56
-
-
Save jgarvin/70d747a9ee9b4b0b5683035d9080643d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun mouse-button-pressed-p () | |
"Return non-nil if last event is a mouse-button down event." | |
(run-hooks 'mouse-leave-buffer-hook) | |
(and (consp last-input-event) | |
(string-match-p "down-mouse-" (format "%s" (car last-input-event))))) | |
(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) ;; old way | |
(mouse-button-pressed-p) ;; new way | |
) | |
(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