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 " "))
User Option: transient-mark-mode
This variable, if non- nil , enables Transient Mark mode. In Transient Mark mode, every buffer-modifying primitive sets deactivate-mark . As a consequence, most commands that modify the buffer also deactivate the mark.
When Transient Mark mode is enabled and the mark is active, many commands that normally apply to the text near point instead apply to the region. Such commands should use the function use-region-p to test whether they should operate on the region. See The Region.
Lisp programs can set transient-mark-mode to non- nil , non- t values to enable Transient Mark mode temporarily. If the value is lambda , Transient Mark mode is automatically turned off after any action, such as buffer modification, that would normally deactivate the mark. If the value is (only . oldval) , then transient-mark-mode is set to the value oldval after any subsequent command that moves point and is not shift-translated (see shift-translation), or after any other action that would normally deactivate the mark.