Skip to content

Instantly share code, notes, and snippets.

@gpittarelli
Last active March 3, 2017 08:45
Show Gist options
  • Select an option

  • Save gpittarelli/52ae21e8d0add764ac83b083d142529e to your computer and use it in GitHub Desktop.

Select an option

Save gpittarelli/52ae21e8d0add764ac83b083d142529e to your computer and use it in GitHub Desktop.

Revisions

  1. gpittarelli revised this gist Mar 3, 2017. 2 changed files with 21 additions and 10 deletions.
    10 changes: 0 additions & 10 deletions xkcd 1806 scrolling in emacs
    Original file line number Diff line number Diff line change
    @@ -1,10 +0,0 @@
    (defun mwheel-scroll (event)
    "Scroll up or down according to the EVENT.
    This should be bound only to mouse buttons 4 and 5 on non-Windows
    systems."
    (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)))))
    21 changes: 21 additions & 0 deletions xkcd-1806-scrolling-in-emacs.el
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    (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)
  2. gpittarelli created this gist Mar 3, 2017.
    10 changes: 10 additions & 0 deletions xkcd 1806 scrolling in emacs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    (defun mwheel-scroll (event)
    "Scroll up or down according to the EVENT.
    This should be bound only to mouse buttons 4 and 5 on non-Windows
    systems."
    (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)))))