diff --git a/extensions/vi-mode/binds.lisp b/extensions/vi-mode/binds.lisp index 6e51c0b70..c6dffc20c 100644 --- a/extensions/vi-mode/binds.lisp +++ b/extensions/vi-mode/binds.lisp @@ -44,8 +44,8 @@ (define-key *motion-keymap* "H" 'vi-move-to-window-top) (define-key *motion-keymap* "M" 'vi-move-to-window-middle) (define-key *motion-keymap* "L" 'vi-move-to-window-bottom) -(define-key *motion-keymap* "C-d" 'next-page) -(define-key *motion-keymap* "C-u" 'previous-page) +(define-key *motion-keymap* "C-d" 'vi-scroll-down) +(define-key *motion-keymap* "C-u" 'vi-scroll-up) (define-key *motion-keymap* "^" 'vi-back-to-indentation) (define-key *motion-keymap* "_" 'vi-back-to-indentation) (define-key *motion-keymap* "{" 'backward-paragraph) diff --git a/extensions/vi-mode/commands.lisp b/extensions/vi-mode/commands.lisp index ab6cfef8e..d2f939f7a 100644 --- a/extensions/vi-mode/commands.lisp +++ b/extensions/vi-mode/commands.lisp @@ -65,6 +65,8 @@ :vi-scroll-line-to-bottom-back-to-indentation :vi-scroll-bottom-line-to-top :vi-scroll-top-line-to-bottom + :vi-scroll-down + :vi-scroll-up :vi-back-to-indentation :vi-indent :vi-substitute @@ -188,6 +190,20 @@ (:type :line) (previous-line n)) +(define-motion vi-scroll-down (&optional (n nil)) (:universal-nil) + (:type :inclusive :default-n-arg nil) + (unless n + (setf n (floor (window-height (current-window)) 2))) + (next-line n) + (scroll-down n)) + +(define-motion vi-scroll-up (&optional (n nil)) (:universal-nil) + (:default-n-arg nil) + (unless n + (setf n (floor (window-height (current-window)) 2))) + (previous-line n) + (scroll-up n)) + (defun on-only-space-line-p (point) (with-point ((p point)) (line-end p) @@ -689,14 +705,23 @@ Move the cursor to the first non-blank character of the line." (defun vi-forward-matching-paren (window point &optional (offset -1)) (declare (ignore window)) (with-point ((point point)) + (loop :until (or (syntax-open-paren-char-p (character-at point)) + (syntax-closed-paren-char-p (character-at point)) + (= (point-charpos point) (length (line-string point)))) + :do (incf (point-charpos point))) (when (syntax-open-paren-char-p (character-at point)) (when (scan-lists point 1 0 t) (character-offset point offset))))) (defun vi-backward-matching-paren (window point &optional (offset -1)) (declare (ignore window offset)) - (when (syntax-closed-paren-char-p (character-at point)) - (scan-lists (character-offset (copy-point point :temporary) 1) -1 0 t))) + (with-point ((point point)) + (loop :until (or (syntax-open-paren-char-p (character-at point)) + (syntax-closed-paren-char-p (character-at point)) + (= (point-charpos point) (length (line-string point)))) + :do (incf (point-charpos point))) + (when (syntax-closed-paren-char-p (character-at point)) + (scan-lists (character-offset (copy-point point :temporary) 1) -1 0 t)))) (define-motion vi-move-to-matching-item (&optional n) (:universal-nil) (:type :inclusive