<div dir="ltr"><div>Hi there,<br>I would like to work on a patch to add support for ]p and [p to evil. I have some working code (see below) to adjust the indent after a call to evil-paste-after / evil-paste-before, but I would appreciate tips on how to integrate this with existing evil code (especially so that ]p will be a single undo step, that evil-paste-pop still works, …).<br>
<br>All the best,<br></div>Johann<br><br>(defun get-common-indent-in-region (start end)<br> (setq end (copy-marker end))<br> (unwind-protect<br> (let (indentation)<br> (save-excursion<br> (goto-char start)<br>
(or (bolp) (forward-line 1))<br> (while (< (point) end)<br> (skip-chars-forward " \t")<br> (setq indentation<br> (cons (current-column) indentation))<br>
(forward-line 1)))<br> (apply #'min indentation))<br> (move-marker end nil)))<br><br>(defun my-evil-adjust-indent-afer-paste ()<br> (interactive)<br><br> (unless (memq last-command<br> '(evil-paste-after<br>
evil-paste-before))<br> (error "Previous command was not a line-wise evil-paste: %s" last-command))<br><br> (let* ((start (evil-get-marker ?\[))<br> (end (evil-get-marker ?\]))<br>
(common (get-common-indent-in-region start end))<br>
(this<br> (save-excursion<br> (cond<br> ((eq last-command 'evil-paste-before)<br> (goto-char end)<br> (forward-line 1))<br> (t<br> (goto-char start)<br>
(forward-line -1)))<br> (skip-chars-forward " \t")<br> (current-column))))<br> (indent-rigidly start end (- this common))))<br></div>