Subject: Re: bug#64730: 30.0.50; Mark activation doesn't work after insert

From: Eli Zaretskii <[email-masked]>
Date: Wed, 19 Jul 2023 18:05:40 +0300

tags 64730 notabug
thanks

> Cc: [email-masked]
> From: Bruno Boal <[email-masked]>
> Date: Wed, 19 Jul 2023 12:17:21 +0100
> 
> I'm trying to evaluate the following snippet in emacs -Q, however as
> soon as I try to insert a character, the region is not highlighted
> anymore. `activate- mark' doesn't make it work either. Whereas
> interactively with `exchange-point-and-mark' the region gets proper highlight.
> 
>        (progn
>          (insert "")
>          (push-mark (line-beginning-position) :no-message :activate))
> 
>        (progn
>          (insert "a")
>          (push-mark (line-beginning-position) :no-message :activate))

This is the intended behavior.  The ELisp manual says in the node "The
Mark":

 -- Variable: deactivate-mark
     If an editor command sets this variable non-‘nil’, then the editor
     command loop deactivates the mark after the command returns (if
     Transient Mark mode is enabled).  All the primitives that change
     the buffer set ‘deactivate-mark’, to deactivate the mark when the
     command is finished.  Setting this variable makes it buffer-local.

     To write Lisp code that modifies the buffer without causing
     deactivation of the mark at the end of the command, bind
     ‘deactivate-mark’ to ‘nil’ around the code that does the
     modification.  For example:

          (let (deactivate-mark)
            (insert " "))