I've been doing my homework: 1) Changing insert for insert-before-markers is problematic because it somehow wreaks havoc with font locking. I guess some other markers are being moved around besides he-string-end, maybe the one pointing to the end of the prompt or something like that (since everything gets colored the same the prompt is). Moreover, the he-string-beg marker would still point to the wrong place no matter what its type were. 2) This will work for the end marker: (set-marker-insertion-type he-string-end t), but it's too invasive regarding hippie-expand. Also, it assumes the user is indeed using hippie-expand. But maybe changing the insertion type of he-string-end just around the delete-region/insert and just in case hippie-expand is currently provided will do the dirty job. Again, this doesn't fix the he-string-beg marker at all. 3) Same as (2) above, but saving/restoring the *positions* of both he-string-beg and he-string-end. This is the best solution I could figure out till now. Take a look at the attached patch, please. What do you think?