From fa9d696806f60e07e41822d9a52cbaba0e5b677c Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Fri, 14 Dec 2012 13:14:05 +0000 Subject: [PATCH] Enable scrolling half a screen with C-v and M-v keybindings --- helpers.el | 17 +++++++++++++++++ keybindings.el | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/helpers.el b/helpers.el index 569eac3..f942914 100644 --- a/helpers.el +++ b/helpers.el @@ -70,6 +70,23 @@ there's a region, all lines that region covers will be duplicated." (yank-pop (- arg))) +;; +;; Scroll Half Screen +;; - from: http://www.emacswiki.org/emacs/HalfScrolling +;; + +(defun window-half-height () + (max 1 (/ (1- (window-height (selected-window))) 2))) + +(defun scroll-up-half () + (interactive) + (scroll-up (window-half-height))) + +(defun scroll-down-half () + (interactive) + (scroll-down (window-half-height))) + + ;; ;; Window Switching ;; diff --git a/keybindings.el b/keybindings.el index cbbcb32..628e13c 100644 --- a/keybindings.el +++ b/keybindings.el @@ -24,6 +24,10 @@ ;; Goto line (global-set-key (kbd "C-c C-l") 'goto-line) +;; Scroll up/down +(global-set-key (kbd "C-v") 'scroll-up-half) +(global-set-key (kbd "M-v") 'scroll-down-half) + ;; Switch to next/previous buffer (global-set-key (kbd "C-c C-n") 'switch-to-next-buffer) (global-set-key (kbd "C-c C-p") 'switch-to-prev-buffer)