Skip to content

Instantly share code, notes, and snippets.

@aont
Last active May 7, 2016 13:14
Show Gist options
  • Select an option

  • Save aont/2b94013230d07e7db13461be8f053161 to your computer and use it in GitHub Desktop.

Select an option

Save aont/2b94013230d07e7db13461be8f053161 to your computer and use it in GitHub Desktop.
optimize scrolling on emacs
(setq scruptime 0)
(global-set-key [mouse-4]
'(lambda ()
(interactive)
(setq scruptime_new (float-time) )
(setq scrup_dt (- scruptime_new scruptime))
(if (> scrup_dt 0.05)
(scroll-down-line 1)
(scroll-down-line (ceiling (/ 0.05 scrup_dt) ) )
)
;(message (number-to-string (ceiling (/ 1 scrup_dt) ) )
;(previous-line (ceiling (/ 0.01 scrup_dt) ) )
(setq scruptime scruptime_new)
;(recenter)
)
;'(lambda () (interactive) (previous-line 1) (recenter) )
)
(setq scrdntime 0)
(global-set-key [mouse-5]
'(lambda ()
(interactive)
(setq scrdntime_new (float-time) )
(setq scrdn_dt (- scrdntime_new scrdntime))
(if (> scrdn_dt 0.05)
(scroll-up-line 1)
(scroll-up-line (ceiling (/ 0.05 scrdn_dt) ) )
)
;(message (number-to-string (ceiling (/ 1 scrup_dt) ) )
;(previous-line (ceiling (/ 0.01 scrup_dt) ) )
(setq scrdntime scrdntime_new)
;(recenter)
)
;'(lambda () (interactive) (previous-line 1) (recenter) )
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment