<div dir="ltr"><div><div>(Sorry to everyone, seems my subscription to this list did not go through so I haven&#39;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&#39;t get to it this month.<br>


<br>(evil-define-command evil-paste-before-adjusting-indent<br>  (count &amp;optional register yank-handler)<br>  &quot;Like `evil-paste-before&#39; but adjusts the indent to the current line.&quot;<br>  :suppress-operator t<br>


  (interactive &quot;P&lt;x&gt;&quot;)<br>  (evil-paste-before count register yank-handler)<br>  (my-evil-adjust-indent-<span>after</span>-paste &#39;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">&lt;<a href="mailto:kljohann@gmail.com" target="_blank">kljohann@gmail.com</a>&gt;</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 (&lt; (point) end)<br>            (skip-chars-forward &quot; \t&quot;)<br>            (setq indentation<br>                  (cons (current-column) indentation))<br>


            (forward-line 1)))<br>        (apply #&#39;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>                &#39;(evil-paste-after<br>


                  evil-paste-before))<br>    (error &quot;Previous command was not a line-wise evil-paste: %s&quot; 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 &#39;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 &quot; \t&quot;)<br>            (current-column))))<br>    (indent-rigidly start end (- this common))))<br></div>
</blockquote></div><br></div>