Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is mark active if and only if region is active in Emacs?

Does "mark is active" simply mean the same thing as "region is active" in Emacs, regardless of whether Transient Mark mode is enabled? Therefore to activate mark is the same as to activate region?

I am confused because two phrases seem to be used interchangeably in many places, while the definition of region-active-p seems to take the stance that region is considered active if and only if Transient Mark mode is enabled and mark is active.

(defun region-active-p ()
  "Return t if Transient Mark mode is enabled and the mark is active.

Some commands act specially on the region when Transient Mark
mode is enabled.  Usually, such commands should use
`use-region-p' instead of this function, because `use-region-p'
also checks the value of `use-empty-active-region'."
  (and transient-mark-mode mark-active))

What is the relation between

  • region is highlighted (i.e. the region is in different background color)

  • region is active

  • mark is active

when Transient Mark mode is enabled, and when it is disabled, respectively?

like image 970
Jisang Yoo Avatar asked Sep 09 '13 12:09

Jisang Yoo


1 Answers

  1. Region is active = mark is active. But it is not necessarily highlighted.

  2. The region is highlighted if active and transient-mark-mode is on.

  3. The region is also highlighted temporarily if you set it using the mouse or using Shift + cursor keys, i.e., even if transient-mark-mode is off.

Except that if the region is empty you won't see any highlighting.

From my point of view, "active" applies only to transient-mark-mode. It has no sense when the mode is turned off. Any function whose behavior depends on whether the region is active only does so when t-m-mode is enabled. As the Emacs manual (node Persistent Mark) says: "When Transient Mark mode is off, the mark is never deactivated"

But this is not how it is spoken of sometimes recently. The reason has to do with "temporary transient-mark-mode" (see the Elisp manual, node The Mark).

(Keep in mind too that if there is not yet any mark in the buffer then there is also no region there.)

like image 134
Drew Avatar answered Oct 17 '22 21:10

Drew