0

Looking into Emacs marks and the active region, it looks fairly simple to write a function in elisp that activates the region, however, is this something emacs is capable of doing via built-in interactive commands?

Or is it necessary to write an elisp function to set the active region between the point and the mark position?

Edit: for clarification, in this case by "active region" I mean.

  • (region-active-p) returns true.
  • The region is visible as a selected block.
  • Since asking this question I'v eseen C-x C-x can be used to do this, although it swaps the point/mark (so it's not just making the region active).

For context: I was considering including the functionality as part of a larger package - which would be redundant if it's already supported.

3
  • See "Setting the Mark": gnu.org/software/emacs/manual/html_node/emacs/Setting-Mark.html Commented Jan 19 at 14:54
  • I'm not sure about the terminology: what does set the active region between the point and the mark mean to you? To me, it just means that transient mark mode is enabled (as it is by default) and the region is highlighted to show what is going to be affected by the next command that affects the region. But the region exists whether it's highlighted or not as long as the mark is set: if I do C-g, the highlight goes away but C-x C-x still switches point and mark (and brings back the highlight). So I'm not quite sure what you are asking. Commented Jan 19 at 20:24
  • @lawlist yes, I read this but it doesn't mention a way to make the point/mark active as a single command. Commented Jan 19 at 22:22

2 Answers 2

1

In your comments you made clear that:

  1. You're looking only for a vanilla Emacs command to activate the region. IOW, you don't want to define your own command (which, as you indicate, is trivial to do).

  2. You don't want to use an existing command twice to do it, e.g., C-x C-x C-x C-x.

  3. You don't want to swap point and mark, i.e., C-x C-x.

The answer to your question is then no, there is no preexisting command to activate the region.

(Please put all the relevant info from your comments into your question. Comments can be deleted at any time.)

1
  • 1
    Thanks, edited the quiestion to give some context. Commented Jan 20 at 1:35
1

The cua-exchange-point-and-mark command does this if you pass it an argument. You can use it without enabling CUA-mode.

(autoload 'cua-exchange-point-and-mark "cua-base") (global-set-key (kbd "C-x C-x") 'cua-exchange-point-and-mark) 

Now "C-1 C-x C-x" activates the region without moving point. And pressing "C-x C-x" without an argument swaps point and mark without activating the region.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.