From 277759d894d2a9c7b2915d1d50aadf3c64a4e1b2 Mon Sep 17 00:00:00 2001 From: Igor Avdeev Date: Thu, 31 Mar 2016 11:46:00 +0300 Subject: Fix repeat action (.) for ys and yS operators. I wrapped ys/yS operators with raw record commands, because they are handled by evil-yank operator, that is marked as not repeatable. --- evil-surround.el | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/evil-surround.el b/evil-surround.el index 0841bcf..d18af37 100755 --- a/evil-surround.el +++ b/evil-surround.el @@ -235,6 +235,16 @@ column." (evil-surround-region ibeg iend t char))) beg end nil))) +(defun evil-surround-call-with-repeat (callback) + "Record keystrokes to repeat surround-region operator and it's motion. +This is necessary because `evil-yank' operator is not repeatable (:repeat nil)" + (evil-repeat-start) + (evil-repeat-record "y") + (evil-repeat-record (this-command-keys)) + (call-interactively callback) + (evil-repeat-keystrokes 'post) + (evil-repeat-stop)) + ;; Dispatcher function in Operator-Pending state. ;; "cs" calls `evil-surround-change', "ds" calls `evil-surround-delete', ;; and "ys" calls `evil-surround-region'. @@ -252,7 +262,7 @@ Otherwise call `evil-surround-region'." (call-interactively 'evil-surround-delete)) (t (evil-surround-setup-surround-line-operators) - (call-interactively 'evil-surround-region)))) + (evil-surround-call-with-repeat 'evil-surround-region)))) (evil-define-command evil-Surround-edit (operation) "Like evil-surround-edit, but for surrounding with additional new-lines. @@ -265,7 +275,7 @@ It does nothing for change / delete." ((eq operation 'delete) nil) (t (evil-surround-setup-surround-line-operators) - (call-interactively 'evil-Surround-region)))) + (evil-surround-call-with-repeat 'evil-Surround-region)))) (evil-define-operator evil-surround-region (beg end type char &optional force-new-line) "Surround BEG and END with CHAR. -- cgit v1.0