Skip to content
Browse files

Switch to a cleaner advice-based version of half-screen scrolling

  • Loading branch information...
1 parent 2e1b4be commit 6b101dfaac48df4011d1c1529f8c48f608e668af @jimeh committed
Showing with 11 additions and 21 deletions.
  1. +11 −0 behavior.el
  2. +0 −17 helpers.el
  3. +0 −4 keybindings.el
View
11 behavior.el
@@ -71,3 +71,14 @@
(if (ac-trigger-command-p last-command)
(auto-complete)
ad-do-it))
+
+;; Scroll half a screen when using scroll-up and scroll-down functions.
+(defadvice scroll-up (around half-window activate)
+ (setq next-screen-context-lines
+ (max 1 (/ (1- (window-height (selected-window))) 2)))
+ ad-do-it)
+
+(defadvice scroll-down (around half-window activate)
+ (setq next-screen-context-lines
+ (max 1 (/ (1- (window-height (selected-window))) 2)))
+ ad-do-it)
View
17 helpers.el
@@ -71,23 +71,6 @@ there's a region, all lines that region covers will be duplicated."
;;
-;; 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
;;
View
4 keybindings.el
@@ -24,10 +24,6 @@
;; 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)

0 comments on commit 6b101df

Please sign in to comment.
Something went wrong with that request. Please try again.