Currently, I am doing the replacement of the word under the cursor on a script using:
(setq bounds (bounds-of-thing-at-point 'word)) (setq pos1 (car bounds)) (setq pos2 (cdr bounds)) (delete-region pos1 pos2) (insert newword)
But this does not preserve the case pattern of the original word. The function
replace-match would preserve case, but it would require me to do a search before; something like this:
(left-word) (search-forward originalword) (replace-match newword)
Is there a
replace command which would allow me to replace the word at point preserving the original word pattern case? If not, am I missing a simple way to write one?