<div dir="ltr"><div><div>(Sorry to everyone, seems my subscription to this list did not go through so I haven't been received your answers. I just stumbled across them via the gmane archive. Thus the reply-to-self.)<br>
<br>
</div>Gordon, Frank, thanks for taking the time to answer.<br>I originally tried to define a command as Gordon mentioned (see below), but this lead to two separate undo steps (pasting and indenting). Regarding evil-paste-pop I think I like the :paste-command suggestion most, I may end up implementing that. As I am short on time currently, I likely won't get to it this month.<br>
<br>(evil-define-command evil-paste-before-adjusting-indent<br> (count &optional register yank-handler)<br> "Like `evil-paste-before' but adjusts the indent to the current line."<br> :suppress-operator t<br>
(interactive "P<x>")<br> (evil-paste-before count register yank-handler)<br> (my-evil-adjust-indent-<span>after</span>-paste 'before))<br><br><br></div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jun 27, 2014 at 2:26 PM, Johann Klähn <span dir="ltr"><<a href="mailto:kljohann@gmail.com" target="_blank">kljohann@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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>
</blockquote></div><br></div>