I accidentally pressed some keys in a buffer and created the permanently highlighted region shown below. What is this region called, and how can I get rid of it?
That permanently highlighted region is the secondary selection.
We deduced this in the comments to your question by putting point in the middle of the highlighted region and by calling M-x
describe-char RET. You get something like the following in the opening
There is an overlay here: From 316781 to 316796 face secondary-selection
You also mentioned in one of your comments that your window manager hides mouse-1 events from Emacs.
One possible solution to that problem could be to define the following key bindings:
(global-set-key [?\e mouse-1] 'mouse-start-secondary) (global-set-key [?\e drag-mouse-1] 'mouse-set-secondary) (global-set-key [?\e down-mouse-1] 'mouse-drag-secondary) (global-set-key [?\e mouse-3] 'mouse-secondary-save-then-kill) (global-set-key [?\e mouse-2] 'mouse-yank-secondary)
These are the secondary selection bindings of
M- replaced by
?\e, the escape key.
So whenever you are asked to use the Meta modifier for a secondary selection command you can press the ESC key before the unmodified key sequence instead.
For an example, press ESC <mouse-1> instead of M-<mouse-1> to get rid of the "strange" highlighting by deleting the secondary selection overlay.
Note, that the secondary selection can become handy when you want to temporarily remember stuff in a selection while using the primary selection as usual. For an example you can mark some stretch of text by the secondary selection, mark and delete some other stretch of text with the primary selection and insert the stuff from the secondary selection with ESC <mouse-2>.