Allow control of indicating empty rectangular selections

* lisp/rect.el (rectangle-indicate-zero-width-rectangle): New user
option.
(rectangle--highlight-for-redisplay): Use it to decide whether to
indicate empty rectangles on display.  (Bug#16403)

* etc/NEWS: Announce the feature.
This commit is contained in:
Eli Zaretskii 2025-03-13 13:35:54 +02:00
parent d29e0add71
commit cecaec20e7
2 changed files with 15 additions and 1 deletions

View file

@ -681,6 +681,14 @@ were also dynamically accumulated in minibuffer history during
minibuffer use, they are now saved only once in the file specified by
'savehist-file'. Previously, they were saved twice.
** Rectangle Mark
---
*** New user option to control whether empty rectangle selections are shown.
The new user option 'rectangle-indicate-zero-width-rectangle' can be
used to disable the default display of empty rectangular selections.
The default is t; set it to nil to disable the indication (which causes
a horizontal shift of text on display, and thus could be annoying).
** Message
---

View file

@ -456,6 +456,11 @@ With a prefix (or a FILL) argument, also fill too short lines."
:version "25.1"
:type 'boolean)
(defcustom rectangle-indicate-zero-width-rectangle t
"If non-nil, make zero-width rectangles visible on display."
:version "31.1"
:type 'boolean)
(defun rectangle--string-preview ()
(when rectangle-preview
(let ((str (minibuffer-contents)))
@ -960,7 +965,8 @@ Ignores `line-move-visual'."
(overlay-put ol 'after-string str))))
((overlay-get ol 'after-string)
(overlay-put ol 'after-string nil)))
(when (and (= leftcol rightcol) (display-graphic-p))
(when (and (= leftcol rightcol) (display-graphic-p)
rectangle-indicate-zero-width-rectangle)
;; Make zero-width rectangles visible!
(overlay-put ol 'after-string
(concat (propertize