Subject: bug#10738: insert before setting the mark means the mark wont be set

From: Stefan Monnier <[email-masked]>
Date: Mon, 06 Feb 2012 16:24:37 -0500

>> From emacs -q, consider the following program:
> (defun foo ()
>   (interactive)
>   (insert "bar")
>   (push-mark)
>   (forward-line)
>   (activate-mark))

> M-x foo, bar appears, but the mark is not set.

> (defun baz ()
>    (interactive)
>    (push-mark)
>    (forward-line)
>    (activate-mark))

> I wouldn't expect a command *before* setting the mark to affect if the
> mark was actually set. Is this a concurrency bug?

The mark gets deactivated after a command that modifies the buffer.
`foo' above is a command that modifies the buffer, so the mark is
deactivated afterwards.  This is done via the
`deactivate-mark' variable.
You can let-bind it around the call to `insert' to prevent that variable
from being set.

        Stefan