I am trying to write a function where I insert some text, and then activate the mark at the end of the function. I have several use-cases where I would like to use this.
I cannot figure out how do make it work. I have the following expression which I am using to test the behavior:
(progn
(set-mark-command nil)
(save-excursion
(insert "hi"))
(forward-line 2)
(activate-mark))
Evaluating this expression does not activate the mark; however, if I comment out the save-excursion part which inserts some text, the mark is activated. Why isn't the mark being activated, and what can I do to make the expression work as expected?