Check for universal arg before paste

This commit fixes #4219 and fixes #8897
This commit is contained in:
Bet4 2018-09-18 20:53:55 +08:00 committed by duianto
parent 4add7d478d
commit 554ca097f2
3 changed files with 21 additions and 18 deletions

View File

@ -19,7 +19,7 @@
(defun spacemacs/evil-mc-paste-after (&optional count register)
"Disable paste transient state if there is more than 1 cursor."
(interactive "p")
(interactive "*P")
(setq this-command 'evil-paste-after)
(if (spacemacs//evil-mc-paste-transient-state-p)
(spacemacs/paste-transient-state/evil-paste-after)
@ -27,7 +27,7 @@
(defun spacemacs/evil-mc-paste-before (&optional count register)
"Disable paste transient state if there is more than 1 cursor."
(interactive "p")
(interactive "*P")
(setq this-command 'evil-paste-before)
(if (spacemacs//evil-mc-paste-transient-state-p)
(spacemacs/paste-transient-state/evil-paste-before)

View File

@ -1313,21 +1313,25 @@ Compare them on count first,and in case of tie sort them alphabetically."
(if (<= (- end beg) spacemacs-yank-indent-threshold)
(indent-region beg end nil)))
(spacemacs|advise-commands
"indent" (yank yank-pop evil-paste-before evil-paste-after) around
"If current mode is not one of spacemacs-indent-sensitive-modes
indent yanked text (with universal arg don't indent)."
(evil-start-undo-step)
ad-do-it
(if (and (not (equal '(4) (ad-get-arg 0)))
(not (member major-mode spacemacs-indent-sensitive-modes))
(or (derived-mode-p 'prog-mode)
(member major-mode spacemacs-indent-sensitive-modes)))
(let ((transient-mark-mode nil)
(save-undo buffer-undo-list))
(spacemacs/yank-advised-indent-function (region-beginning)
(region-end))))
(evil-end-undo-step))
(defun spacemacs//yank-indent-region (yank-func &rest args)
"If current mode is not one of spacemacs-indent-sensitive-modes
indent yanked text (with universal arg don't indent)."
(evil-start-undo-step)
(let ((prefix (car args)))
(setcar args (unless (equal '(4) prefix) prefix))
(apply yank-func args)
(if (and (not (equal '(4) prefix))
(not (member major-mode spacemacs-indent-sensitive-modes))
(or (derived-mode-p 'prog-mode)
(member major-mode spacemacs-indent-sensitive-modes)))
(let ((transient-mark-mode nil)
(save-undo buffer-undo-list))
(spacemacs/yank-advised-indent-function (region-beginning)
(region-end)))))
(evil-end-undo-step))
(dolist (func '(yank yank-pop evil-paste-before evil-paste-after))
(advice-add func :around #'spacemacs//yank-indent-region))
;; find file functions in split
(defun spacemacs//display-in-split (buffer alist)

View File

@ -61,7 +61,6 @@ Otherwise, revert to the default behavior (i.e. enable `evil-insert-state')."
(evil-escape-mode t)
(evil-escape-mode -1)))
(defun spacemacs/linum-relative-toggle ()
(interactive)
(if (not (bound-and-true-p linum-relative-mode))