Is a sign active if and only if the region is active in Emacs?

Does “sign active” mean just the same as “region active” in Emacs, regardless of whether the transition sign mode is on? Therefore, activate the mark in the same way as activating a region?

I am confused because the two phrases seem to be used interchangeably in many places, while the definition of region-active-p seems to take the position that the region is considered active if and only when the Transient Mark mode is on and the sign 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 relationship between

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

    Region
  • active

  • sign is active

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

+6
source share
2 answers
  • Area active = sign active. But this does not necessarily stand out.

  • The area is highlighted if the timestamp mode is active and enabled.

  • The region is also temporarily highlighted if you set it with the mouse or with the Shift + cursor keys, i.e. even if time stamp mode is disabled.

In addition, if the area is empty, you will not see the highlight.

From my point of view, “active” refers only to transition mark mode. This does not make sense when the mode is off. Any function whose behavior depends on whether the area is active when tm-mode is on. The Emacs manual (node Persistent Mark ) says: "When the Transient Mark mode is off, the sign is never deactivated."

But this is not how they say it recently. The reason is related to the "temporary transition marker" (see Elisp Manual, node The Mark ).

(Remember also that if there is no label in the buffer yet, then there is also no area.)

+6
source

Side note. Here is a tracking method when mark-active is true. Rate the following code:

 (defun my-message-mark-active () (set-background-color (if mark-active "grey90" "white"))) (defvar my-watch-mark-active-mode nil) (defun my-watch-mark-active-mode () (interactive) (if my-watch-mark-active-mode (progn (cancel-timer my-watch-mark-active-mode) (setq my-watch-mark-active-mode nil) (message "off")) (setq my-watch-mark-active-mode (run-with-idle-timer 0.1 t #'my-message-mark-active)) (message "on"))) 

Then enter Mx my-watch-mark-active-mode to enable tag viewing. The background color is grey90, and mark-active is true, otherwise it is white. Type Mx my-watch-mark-active-mode to turn it off.

This will help to ensure that when the timestamp mode is turned on, the marker is active if and only if the area is selected. And it also checks that when timestamp mode is disabled, mark-active becomes true at some point, and then never becomes false, this is for each buffer.

0
source

Source: https://habr.com/ru/post/953485/


All Articles