Skip to content

Instantly share code, notes, and snippets.

@gpittarelli
Last active March 3, 2017 08:45
Show Gist options
  • Save gpittarelli/52ae21e8d0add764ac83b083d142529e to your computer and use it in GitHub Desktop.
Save gpittarelli/52ae21e8d0add764ac83b083d142529e to your computer and use it in GitHub Desktop.
Scroll through time, not space! like xkcd 2806, in emacs
(defun mwheel-scroll (event)
(interactive (list last-input-event))
(let ((button (mwheel-event-button event)))
(cond ((eq button mouse-wheel-down-event)
(undo-tree-undo))
((eq button mouse-wheel-up-event)
(undo-tree-redo)))))
;; ^ global override for all scrollwheel events
;; to do it only for shift+scroll, try:
(defun mwheel-scroll-through-time (event)
(interactive (list last-input-event))
(let ((button (mwheel-event-button event)))
(cond ((eq button mouse-wheel-down-event)
(undo-tree-undo))
((eq button mouse-wheel-up-event)
(undo-tree-redo)))))
(global-set-key (kbd "<S-mouse-4>") 'mwheel-scroll-through-time)
(global-set-key (kbd "<S-mouse-5>") 'mwheel-scroll-through-time)
@gpittarelli
Copy link
Author

gpittarelli commented Mar 3, 2017

Lets you do the "scrolling through time instead of space" of the title text of https://xkcd.com/1806/ in emacs :)

You'll need to M-x package-install RET undo-tree if you don't have undo-tree yet (provides easy undo-tree-{undo,redo})

Demo (undoing/redoing over me implementing this) at https://www.gjp.cc/i/scroll-so-fast.webm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment