evil: work on support for ]p, [p (adjust indent on paste)

Johann Klähn kljohann at gmail.com
Fri Jun 27 14:26:57 CEST 2014

Hi there,
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, …).

All the best,

(defun get-common-indent-in-region (start end)
  (setq end (copy-marker end))
      (let (indentation)
          (goto-char start)
          (or (bolp) (forward-line 1))
          (while (< (point) end)
            (skip-chars-forward " \t")
            (setq indentation
                  (cons (current-column) indentation))
            (forward-line 1)))
        (apply #'min indentation))
    (move-marker end nil)))

(defun my-evil-adjust-indent-afer-paste ()

  (unless (memq last-command
    (error "Previous command was not a line-wise evil-paste: %s"

  (let* ((start (evil-get-marker ?\[))
         (end (evil-get-marker ?\]))
         (common (get-common-indent-in-region start end))
             ((eq last-command 'evil-paste-before)
              (goto-char end)
              (forward-line 1))
              (goto-char start)
              (forward-line -1)))
            (skip-chars-forward " \t")
    (indent-rigidly start end (- this common))))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.ourproject.org/pipermail/implementations-list/attachments/20140627/c223ad67/attachment.htm 

More information about the implementations-list mailing list