Skip to content

Instantly share code, notes, and snippets.

@herbertjones
Last active August 29, 2015 14:15
Show Gist options
  • Save herbertjones/c4fca060e531fdfd5828 to your computer and use it in GitHub Desktop.
Save herbertjones/c4fca060e531fdfd5828 to your computer and use it in GitHub Desktop.
Playing with a spacemacs-like scrolling micro state
;; Old syntax
(evil-leader/set-key
"," 'hfj/scroll-page-down
"." 'hfj/scroll-page-up
)
(defun hfj/scroll-page-overlay-map ()
"Set a temporary overlay map to easily scroll through a file."
(set-temporary-overlay-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd ",") 'hfj/scroll-page-down)
(define-key map (kbd ".") 'hfj/scroll-page-up)
(define-key map (kbd "SPC") '(lambda () (interactive) t))
map) t))
(defun hfj/scroll-page-micro-state-doc ()
"Display a short documentation in the mini buffer."
(echo "Scroll Page micro-state: .: page up ,: page down"))
(defun hfj/scroll-page-up-or-down (direction)
"-1 for down, 1 for up"
(interactive)
(if (< direction 0)
(evil-scroll-page-down 1)
(evil-scroll-page-up 1))
(hfj/scroll-page-overlay-map)
(hfj/scroll-page-micro-state-doc))
(defun hfj/scroll-page-up ()
"Micro state page up"
(interactive)
(hfj/scroll-page-up-or-down 1))
(defun hfj/scroll-page-down ()
"Micro state page down"
(interactive)
(hfj/scroll-page-up-or-down -1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment