Fork me on GitHub
#emacs
<
2016-03-10
>
peeja16:03:54

What's the canonical way in Emacs Lisp to replace some region of a buffer with a different string? That is, I've placed markers at the start and end of the text I want to replace, and I want to delete that text and replace it with something I have in a variable.

peeja16:03:57

I'm not sure how to do it without setting point and mark, which doesn't feel like I'm doing the right thing

peeja16:03:47

Actually, I can delete-region an arbitrary region, but I can't figure out how to insert at a position that isn't point

peeja17:03:23

Is save-excursion and goto-char the right thing to do?

christianromney20:03:07

not sure if it’s right, but looking at replace-string might help

christianromney20:03:24

when i invoke from a command on a region it does what you describe

christianromney20:03:41

oh nm you want to replace a region with a string

christianromney20:03:50

not one string with another in a region