On 17 dec, 20:47, Andreas Politz <poli...@fh-trier.de> wrote:
Why not work with a string, instead of messing with your buffers undo history.
(defun kill-save-indent-region (indent start end)
(interactive "p\nr")
(kill-new (replace-regexp-in-string
"^" ;or "^\\s-*"
(format (format "%%%ds" (case indent
(0 1)
(1 4)
(t indent)))
"")
(buffer-substring start end)))
(deactivate-mark))
Looking at your code I should replace:
(indent-rigidly (region-beginning) (region-end) indent)
(if do-kill
(kill-region (region-beginning) (region-end))
(copy-region-as-kill (region-beginning) (region-end))
(undo)
)
with:
(kill-new (replace-regexp-in-string
"^"
(format (format "%%%ds" indent) "")
(filter-buffer-substring (region-beginning) (region-
end) do-kill)
)
)
but then I get that filter-buffer-substring is void. What am I doing
wrong?