(in-package :editor) (setup-indent 'def-vim-change 4) (defmacro def-vim-change (name lambda-list command-doc function-doc &body body) `(defcommand ,name ,lambda-list ,command-doc ,function-doc (in-vim-command (setf w-vim-collecting-count nil *vim-last-action* (lambda (,(car lambda-list)) ,@body)) (funcall *vim-last-action* ,(car lambda-list))))) (defun finish-pending-motion (move) (flet ((command (p) (move-point b-vim-point-before-movement (current-point)) (funcall move p) (move-point b-vim-point-after-movement (current-point)) (funcall *vim-pending-action* b-vim-point-before-movement b-vim-point-after-movement))) (command nil) (setf *vim-last-action* #'command *vim-repeat-multiplier* nil) ; FIXME: (restore-modes) (setf (buffer-minor-mode (current-buffer) "Vim Operator Pending") nil) (setf (buffer-minor-mode (current-buffer) "Vim Command") t) )) (setup-indent 'def-vim-move 6) (defmacro def-vim-move (name lambda-list linewise exclusive command-doc function-doc &body body) (let ((p (car lambda-list)) (excl (gensym)) (move (gensym)) (default-repeat (gensym))) `(defcommand ,name ,lambda-list ,command-doc ,function-doc (in-vim-command (setf w-vim-collecting-count nil) (let ((,excl ,exclusive) (,default-repeat (when (or *vim-repeat-multiplier* ,p) (* (or *vim-repeat-multiplier* 1) (or ,p 1))))) (when (eql ,excl :inclusive) (setf ,excl nil)) (flet ((,move (,p) (unless ,p (setf ,p ,default-repeat)) (setf b-vim-linewise ,linewise b-vim-exclusive ,excl) ,@body)) (if (vim-operator-pending-mode-p) (finish-pending-motion #',move) (,move nil)))))))) (defmacro def-vim-movement-pending (name lambda-list command-doc function-doc &body body) `(defcommand ,name (p) ,command-doc ,function-doc (in-vim-command (setf w-vim-collecting-count nil *vim-repeat-multiplier* p *vim-pending-action* (lambda ,lambda-list ,@body)) ; FIXME: (save-modes) (setf (buffer-minor-mode (current-buffer) "Vim Command") nil) (setf (buffer-minor-mode (current-buffer) "Vim Operator Pending") t))))