In Emacs, "the region", which may or may not be highlighted, lies between (point)
and (mark)
.
Since mark can be positioned before or after point, the utility functions region-beginning
and region-end
will return the smaller and the larger of the two, respectively.
(mark)
will return nil
if the mark has never been set in the buffer, in which case both region-beginning
and region-end
will signal an error. A non-nil value of mark doesn't imply that a region is currently highlighted. Whether the region is considered active is also affected by transient-mark-mode
and mark-even-if-inactive
options. The function use-region-p
can be used to test whether it is appropriate to act on the region.