Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
(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
(defvar etc-recenter-timer nil)
(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
You can’t perform that action at this time.