diff options
| author | Eugene Triguba <hello@eugenetriguba.com> | 2026-04-06 07:34:05 -0400 |
|---|---|---|
| committer | Eugene Triguba <hello@eugenetriguba.com> | 2026-04-06 07:34:05 -0400 |
| commit | d4f779d7d43bef2c655c1b3c44e5d92644989dca (patch) | |
| tree | b893c9da85b9d76414000095f6b476c527a0488b /.emacs.d/lisp/et-navigation.el | |
| parent | Replace slime with sly (diff) | |
| download | dotfiles-d4f779d7d43bef2c655c1b3c44e5d92644989dca.zip | |
Update emacs config to use project.el
Diffstat (limited to '.emacs.d/lisp/et-navigation.el')
| -rw-r--r-- | .emacs.d/lisp/et-navigation.el | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/.emacs.d/lisp/et-navigation.el b/.emacs.d/lisp/et-navigation.el new file mode 100644 index 0000000..e434ade --- /dev/null +++ b/.emacs.d/lisp/et-navigation.el @@ -0,0 +1,39 @@ +;;; et-navigation.el --- Emacs navigation utiltiies -*- lexical-binding: t; -*- +;; +;;; Commentary: +;; +;; This module overrides the "scroll up page" and "scroll down page" +;; default Emacs key mappings to only scroll up and down half a page. +;; +;;; Code: + +(global-set-key (kbd "C-v") + 'et-scroll-down-half-page) + +(global-set-key (kbd "M-v") + 'et-scroll-up-half-page) + +(defun et-scroll-down-half-page () + "Scroll down half a page while keeping the cursor centered." + (interactive) + (let ((ln (line-number-at-pos)) + (lmax (line-number-at-pos (point-max)))) + (cond ((= ln 1) (move-to-window-line nil)) + ((= ln lmax) (recenter (window-end))) + (t (progn + (move-to-window-line -1) + (recenter)))))) + +(defun et-scroll-up-half-page () + "Scroll up half a page while keeping the cursor centered." + (interactive) + (let ((ln (line-number-at-pos)) + (lmax (line-number-at-pos (point-max)))) + (cond ((= ln 1) nil) + ((= ln lmax) (move-to-window-line nil)) + (t (progn + (move-to-window-line 0) + (recenter)))))) + +(provide 'et-navigation) +;;; et-navigation.el ends here |