2

Imagine one wants to apply two functions (A and B, where A could be commenting the code with M-; and B convert the text to all-caps with C-x C-u) to the same active region. I would proceed as follows:

  1. set the mark with C-<SPC>
  2. move the cursor until the end of the region I want to modify
  3. run function A
  4. repeat 1. and 2.
  5. run function B

How should I proceed to run both A and B (and potentially others) without repeating the selection step? It seems this behavior arises since most functions which work on an active region implicitly call deactivate-mark on completion.


The question above highlights one of the use cases described in this other post.

2
  • 1
    While the answer to the other question duplicate the answer here, the questions are very different. If I was searching for the answer to 'how to apply multiple actions to the region', how would I know to search for 'what is the use of exchange mark and point'?
    – Tyler
    Commented Aug 25, 2021 at 16:36
  • @Tyler: Completely agree, but cannot reopen the question by myself. I myself only found the other question after reading the accepted answer. Commented Aug 26, 2021 at 7:59

1 Answer 1

3

At step 4, do C-x C-x (exchange-point-and-mark) which will reactivate the mark as it swaps point and mark (and so takes point back to where you started in Step 1).

1
  • Thank you. I had dismissed this option because it seemed not to work, but upon further inspection I realized it was being overridden by cua-mode. One either deactivates cua-mode, or else uses the following: (require 'cua-base) (progn (define-key cua-global-keymap (kbd "C-x C-x") 'exchange-dot-and-mark) ) where exchange-dot-and-mark is an alias for exchange-point-and-mark, but has no predefined keybind. Commented Aug 25, 2021 at 16:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.