emacs - Keyboard scrolling with acceleration -


one can map key scroll up.

(defun up1()   (interactive)   (scroll-up 1)) (defun up2()   (interactive)   (scroll-up 2)) (global-set-key "\m-]" 'up2) 

i looking instead following behavior. first handful of scrolls call up1() , subsequent ones call up2().

how this:

(setq my-scroll-counter 0) (setq my-scroll-limit 5)  (defun up1()   (interactive)   (if (eq last-command this-command)       (incf my-scroll-counter)     (setq my-scroll-counter 0))   (if (> my-scroll-counter my-scroll-limit)        (scroll-up 2)     (scroll-up 1)))  (global-set-key "\m-]" 'up1) 

if want little fancier, calculate scroll step dynamically based on how many times repeat command:

(setq my-scroll-counter 0) (setq my-maximum-scroll 20) (setq my-scroll-acceleration 4)  (defun up1()   (interactive)   (if (eq last-command this-command)       (incf my-scroll-counter)     (setq my-scroll-counter 0))   (scroll-up (min                 (+ 1 (/ my-scroll-counter my-scroll-acceleration))                 my-maximum-scroll)))  (global-set-key "\m-]" 'up1) 

Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -