diff --git a/evil-commands.el b/evil-commands.el index dccd254c..583f6c10 100644 --- a/evil-commands.el +++ b/evil-commands.el @@ -4397,6 +4397,24 @@ The \"!\" argument means to sort in reverse order." ;;; Window navigation +(defvar evil--window-digit 0) + +(defun evil-window-digit () + (if (eq 'evil-window-digit-argument last-command) + evil--window-digit + (setq evil--window-digit 0))) + +(defun evil-window-digit-argument () + "Like `digit-argument' but maintains the window map." + (interactive) + (evil-window-digit) ;; i.e. reset if necessary + (let* ((char (if (integerp last-command-event) + last-command-event + (get last-command-event 'ascii-character))) + (digit (- (logand char ?\177) ?0))) + (setq evil--window-digit (+ (* 10 evil--window-digit) digit)) + (set-transient-map evil-window-map))) + (defmacro evil-save-side-windows (&rest body) "Toggle side windows, evaluate BODY, restore side windows." (declare (indent defun) (debug (&rest form))) @@ -4659,25 +4677,29 @@ and open a new buffer name or edit a certain FILE." "Increase current window height by COUNT." :repeat nil (interactive "p") - (enlarge-window count)) + (let ((win-count (evil-window-digit))) + (enlarge-window (* count (if (< 0 win-count) win-count 1))))) (evil-define-command evil-window-decrease-height (count) "Decrease current window height by COUNT." :repeat nil (interactive "p") - (enlarge-window (- count))) + (let ((win-count (evil-window-digit))) + (enlarge-window (- (* count (if (< 0 win-count) win-count 1)))))) (evil-define-command evil-window-increase-width (count) "Increase current window width by COUNT." :repeat nil (interactive "p") - (enlarge-window count t)) + (let ((win-count (evil-window-digit))) + (enlarge-window (* count (if (< 0 win-count) win-count 1)) t))) (evil-define-command evil-window-decrease-width (count) "Decrease current window width by COUNT." :repeat nil (interactive "p") - (enlarge-window (- count) t)) + (let ((win-count (evil-window-digit))) + (enlarge-window (- (* count (if (< 0 win-count) win-count 1))) t))) (evil-define-command evil-window-set-height (count) "Set the height of the current window to COUNT." diff --git a/evil-maps.el b/evil-maps.el index b0b29532..e94d78f4 100644 --- a/evil-maps.el +++ b/evil-maps.el @@ -188,6 +188,16 @@ (define-key evil-window-map [C-up] 'evil-window-up) (define-key evil-window-map [C-left] 'evil-window-left) (define-key evil-window-map [C-right] 'evil-window-right) +(define-key evil-window-map "0" 'evil-window-digit-argument) +(define-key evil-window-map "1" 'evil-window-digit-argument) +(define-key evil-window-map "2" 'evil-window-digit-argument) +(define-key evil-window-map "3" 'evil-window-digit-argument) +(define-key evil-window-map "4" 'evil-window-digit-argument) +(define-key evil-window-map "5" 'evil-window-digit-argument) +(define-key evil-window-map "6" 'evil-window-digit-argument) +(define-key evil-window-map "7" 'evil-window-digit-argument) +(define-key evil-window-map "8" 'evil-window-digit-argument) +(define-key evil-window-map "9" 'evil-window-digit-argument) (when (featurep 'tab-bar) (define-key evil-motion-state-map "gt" 'evil-tab-next)