emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: visual-region-mode?


From: Drew Adams
Subject: RE: visual-region-mode?
Date: Mon, 24 Sep 2018 13:39:18 -0700 (PDT)

> > Without highlighting, a different indicator could be useful to show
> > whether the region is active or not, like a hint in the mode line.
> 
> Yes, offering an indicator in the mode line to show whether the
> region is active would be a good start.

FWIW, my library `modeline-posn.el' provides such a mode-line
indication.

When the region is active, `size-indication-mode' does these things
(optionally):

* Shows the size of the region (or the shape/size if rectangular),
   instead of the buffer size.
* Shows that the current command acts on the active region or
   acts specially because the region is active.

You can customize the info for the first bullet. Choices for this include
(a) the number of chars, (b) the number of bytes, (c) the number of
chars and number of lines (or the number of rows and number of
columns, if a rectangle is selected), and (d) anything else you
might want.  Choice (c) is the default (shown in attached screenshot).

Option `modelinepos-empty-region-flag' determines whether to
show the active-region indication when the active region is empty.

Attached screenshot shows the mode-line indication. The red box
on the face indicates that the region is active, and it currently has
149 characters.

It shows Isearch restricted to the region (an Isearch+ feature).
The region changes while searching (because the cursor moves),
so the region size (number of chars) also indicates the cursor
position relative to the original start of the region.

The face used to highlight the `size-indication-mode' part of
the mode-line changes to reflect region activation. If the current
command did not treat the active region specially then the face
in the screenshot would not include the surrounding red box. It
would just show the region-face background (by default).
(Two faces are used for the size highlighting: one for normal
and one to show that the current command acts specially.)

Commands use variable `modelinepos-region-acting-on' to
control when to show that they act specially on the region.
For example, this is how I make `rectangle-mark-mode'
turn this indication on and off:

(defadvice rectangle-mark-mode (after
                                bind-modelinepos-region-acting-on
                                activate)
  (setq modelinepos-region-acting-on  rectangle-mark-mode
        modelinepos-rect-p            rectangle-mark-mode)  
  (redisplay 'force))

https://www.emacswiki.org/emacs/ModeLinePosition

Attachment: drew-emacs-modeline-region-isearch.png
Description: PNG image


reply via email to

[Prev in Thread] Current Thread [Next in Thread]