Function: exchange-point-and-mark
exchange-point-and-mark is an interactive and byte-compiled function
defined in simple.el.gz.
Signature
(exchange-point-and-mark &optional ARG)
Documentation
Put the mark where point is now, and point where the mark is now.
This command works even when the mark is not active, and it reactivates
the mark unless exchange-point-and-mark-highlight-region is nil.
If Transient Mark mode is on, a prefix ARG deactivates the mark if it is
active, and otherwise avoids reactivating it. However, if
exchange-point-and-mark-highlight-region is nil, then using a prefix
argument does reactivate the mark; effectively, when Transient Mark mode
is on, setting exchange-point-and-mark-highlight-region to nil swaps
the meanings of the presence and absence of a prefix argument.
If Transient Mark mode is off, a prefix ARG enables Transient Mark mode temporarily.
This function has :after advice: org-mark-jump-unhide.
Probably introduced at or before Emacs version 17.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/simple.el.gz
(defun exchange-point-and-mark (&optional arg)
"Put the mark where point is now, and point where the mark is now.
This command works even when the mark is not active, and it reactivates
the mark unless `exchange-point-and-mark-highlight-region' is nil.
If Transient Mark mode is on, a prefix ARG deactivates the mark if it is
active, and otherwise avoids reactivating it. However, if
`exchange-point-and-mark-highlight-region' is nil, then using a prefix
argument does reactivate the mark; effectively, when Transient Mark mode
is on, setting `exchange-point-and-mark-highlight-region' to nil swaps
the meanings of the presence and absence of a prefix argument.
If Transient Mark mode is off, a prefix ARG enables Transient Mark mode
temporarily."
(interactive "P")
(let ((omark (mark t))
(region-was-active (region-active-p))
(temp-highlight (eq (car-safe transient-mark-mode) 'only)))
(if (null omark)
(user-error "No mark set in this buffer"))
(set-mark (point))
(goto-char omark)
(cond (temp-highlight)
((xor arg (if exchange-point-and-mark-highlight-region
(not (region-active-p))
(not region-was-active)))
(deactivate-mark))
(t (activate-mark)))
nil))