Skip to content

Commit

Permalink
Fix pasting with universal argument
Browse files Browse the repository at this point in the history
The auto-indent advice around evil-paste-{before,after} calls the advised funcs
without removing the universal argument. This results in errors like:

ad-Advice-evil-paste-before: Wrong type argument: number-or-marker-p, (4)

and, ultimately, in the paste failing.

This checks for the universal argument *before* calling the advised funcs,
adjusting the args to remove the universal argument.

Fixes syl20bnr#4219
Fixes syl20bnr#8897
  • Loading branch information
pritambaral committed Jan 17, 2019
1 parent 990290e commit 18a3ca6
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions layers/+spacemacs/spacemacs-defaults/funcs.el
Original file line number Diff line number Diff line change
Expand Up @@ -1318,15 +1318,17 @@ Compare them on count first,and in case of tie sort them alphabetically."
"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))))
(let ((universal (equal '(4) (ad-get-arg 0))))
(if universal (ad-set-args 0 (ad-get-args 1)))
ad-do-it
(if (and (not universal)
(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))

;; find file functions in split
Expand Down

0 comments on commit 18a3ca6

Please sign in to comment.