Deactivate Mark

If you’re like me, you probably don’t think very much about activating and deactivating the mark. We know it gets set when we do a large movement or when we set it manually with Ctrl+Space. We know that the current region is defined by the point and mark and maybe even that we can jump to a whole list of current and previous marks.

Leave it to Marcin Borkowski (mbork), who’s an expert at teasing out Emacs minutia, to discover and explain some of the mystery surrounding the deactivation of the mark. It turns out that there’s both a function and variable named deactive-mark. The function does just what it says on the tin: if you call it, the mark is deactivated.

The use of the variable is a little more complicated. The TL;DR is that Emacs has its own notions about when to deactivate the mark and that this is mediated through the deactivate-mark variable. Being Emacs, a user can, of course, change Emacs’ default ideas of mark deactivation. You can read all the details in mbork’s post.

The truth is that you’ll probably never need to fine tune Emacs’ mark activation/deactivation but if you’re writing a function that depends on the current mark being maintained, you should definitely take a look at mbork’s posts to learn how to avoid having Emacs change it out from under you.

Update [2021-04-14 Wed 18:04]: Added link to mbork’s post.

This entry was posted in General and tagged . Bookmark the permalink.