Skip to content

Commit

Permalink
Check for universal arg before paste
Browse files Browse the repository at this point in the history
This commit fixes syl20bnr#4219 and fixes syl20bnr#8897
  • Loading branch information
bet4it committed Oct 28, 2018
1 parent f5243bb commit b714c6c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
4 changes: 2 additions & 2 deletions layers/+misc/multiple-cursors/funcs.el
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@

(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)
(evil-paste-after count (or register evil-this-register))))

(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)
Expand Down
34 changes: 19 additions & 15 deletions layers/+spacemacs/spacemacs-defaults/funcs.el
Original file line number Diff line number Diff line change
Expand Up @@ -1294,21 +1294,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)
Expand Down
6 changes: 3 additions & 3 deletions layers/+spacemacs/spacemacs-evil/funcs.el
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ 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))
(linum-mode))
(linum-relative-toggle))



;; vi-tilde-fringe

(defun spacemacs/disable-vi-tilde-fringe ()
Expand All @@ -80,7 +80,7 @@ Otherwise, revert to the default behavior (i.e. enable `evil-insert-state')."
(when buffer-read-only
(spacemacs/disable-vi-tilde-fringe)))



;; lisp state

(defun spacemacs//load-evil-lisp-state ()
Expand Down

0 comments on commit b714c6c

Please sign in to comment.