I would like to have a command that inserts some text at a distance, while keeping the point in place during its own execution and while being undone.
To illustrate the point, consider following example:
(save-excursion (goto-char (point-at-eol)) (insert "test"))
As I was writing this, I found a solution through making an invisible change at the original position, at the beginning and at the end of execution. This will ensure that original position is the last position visited by point during undo or redo.
Following solution works, however I would like to apply more conventional approach if one exists:
(atomic-change-group (insert " ") (delete-char -1) (save-excursion (goto-char (point-at-eol)) (insert "test")) (insert " ") (delete-char -1))