tags:

views:

207

answers:

1

In emacs, after an operation such as comment-region, the selected region is automatically deselected.

Is there any way of disabling this behaviour?

+2  A: 

If the region is deselected, that sounds like you must be using transient-mark-mode. In transient-mark-mode, when you execute a command that operates on the region, the region is deselected (in particular, the mark remains, but it is inactive). You can reselect the region (reactivate the mark) using C-x C-x (exchange-point-and-mark).

If you want to disable the deselection entirely, you can turn off transient-mark-mode. This means that you won't get any highlighting of the current region, though if you would like to set the mark and highlight the region, you can turn on transient mark mode briefly using C-<SPC> C-<SPC> or C-u C-x C-x.

Brian Campbell
EoghanM
That's rather odd. Do you have something else in your .emacs that enables transient mark mode? Or is there something in a particular major mode you're using that forces transient mark mode on?
Brian Campbell
grep -r "transient" ~/.emacs.d/ turns up nothing, and nothing in ~/.emacs
EoghanM
slink pointed me towards the answer - with transient-mark-mode off, the behaviour doesn't seem to have changed (still a 'transient' highlighting of region), but the region does seem to be permanent.
EoghanM
Hmm, interesting. It doesn't work that way in my version of Emacs; I'm running GNU Emacs 22.3, perhaps you're running a different version? Glad you got it working, anyhow.
Brian Campbell
I'm running 23.0
EoghanM