Advertisement
mark-naylor-1701

emacs half window scroll

Apr 5th, 2024 (edited)
831
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.80 KB | None | 0 0
  1. ;;; This paste is basically redundant. After I wrote the functions, I did some
  2. ;;; internet searching and found that these following functions are already in
  3. ;;; view.el, a part of the core emacs code. No regrets at writing them, because
  4. ;;; I learned more about elisp in the process.
  5.  
  6. ;; View-scroll-half-page-forward
  7. ;; View-scroll-half-page-backward
  8.  
  9. ;;; I'm still debating if I want to bind the View-* commands to keys and/or
  10. ;;; aliases.
  11.  
  12. ;; Commands
  13.  
  14. (defun scroll-up-half-window ()
  15.   (interactive)
  16.   (goto-center-row)
  17.   (recenter-top-bottom 0))
  18.  
  19. (defun scroll-down-half-window ()
  20.   (interactive)
  21.   (goto-center-row)
  22.   (recenter-top-bottom -1))
  23.  
  24. ;; Support function
  25. (defun goto-center-row ()
  26.   (let ((recenter-positions  '(middle top bottom)))
  27.     (move-to-window-line-top-bottom)))
  28.  
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement