diff --git a/spacemacs/packages.el b/spacemacs/packages.el index 14f27cfde..4684a2300 100644 --- a/spacemacs/packages.el +++ b/spacemacs/packages.el @@ -669,6 +669,44 @@ which require an initialization must be listed explicitly in the list.") ("<" spacemacs/scroll-half-page-up) (">" spacemacs/scroll-half-page-down)) + ;; pasting micro-state + (spacemacs|define-micro-state paste + :doc "keep pressing [p] or [P] to cycle between previous or next yanked text" + :bindings + ("p" spacemacs/paste-pop) + ("P" spacemacs/paste-pop-next)) + + (defun spacemacs/paste-pop (count) + "Paste and pop yank ring" + (interactive "p") + (setq last-command 'evil-paste-before) + (evil-paste-pop count)) + + (defun spacemacs/paste-pop-next (count) + "Paste and pop yank ring with negative argument" + (interactive "p") + (setq last-command 'evil-paste-before) + (evil-paste-pop-next count)) + + (evil-define-command spacemacs/paste-before + (count &optional register yank-handler) + "Paste yanked text before point and switch to micro-state." + (interactive "P") + (evil-paste-before count register yank-handler) + (setq last-command 'evil-paste-before) + (spacemacs/paste-micro-state)) + + (evil-define-command spacemacs/paste-after + (count &optional register yank-handler) + "Paste yanked text after point and switch to micro-state." + (interactive "P") + (evil-paste-after count register yank-handler) + (setq last-command 'evil-paste-after) + (spacemacs/paste-micro-state)) + + (define-key evil-normal-state-map "p" 'spacemacs/paste-after) + (define-key evil-normal-state-map "P" 'spacemacs/paste-before) + ;; define text objects (defmacro spacemacs|define-and-bind-text-object (key name start-regex end-regex) (let ((inner-name (make-symbol (concat "evil-inner-" name)))