Subject: Re: bug#42663: 28.0.50; rectangle-mark-mode does not behave as documented when transient-mark-mode is off

From: Sean Whitton <[email-masked]>
Date: Mon, 27 Dec 2021 13:04:07 -0700

Hello,

On Sat 25 Dec 2021 at 09:55AM +02, Eli Zaretskii wrote:

>> --- a/doc/emacs/killing.texi
>> +++ b/doc/emacs/killing.texi
>> @@ -923,11 +923,11 @@ Rectangles
>>  @findex rectangle-mark-mode
>>    The command @kbd{C-x @key{SPC}} (@code{rectangle-mark-mode}) toggles
>>  whether the region-rectangle or the standard region is highlighted
>> -(first activating the region if necessary).  When this mode is enabled,
>> -commands that resize the region (@kbd{C-f}, @kbd{C-n} etc.)@: do
>> -so in a rectangular fashion, and killing and yanking operate on the
>> -rectangle.  @xref{Killing}.  The mode persists only as long as the
>> -region is active.
>> +(first activating the region if necessary, unless Transient Mark mode
>> +is off).  When this mode is enabled, commands that resize the region
>> +(@kbd{C-f}, @kbd{C-n} etc.)@: do so in a rectangular fashion, and
>> +killing and yanking operate on the rectangle.  @xref{Killing}.  The
>> +mode persists until the next time the region becomes inactive.
>
> The new text is IMO not accurate, because toggling the mode doesn't
> depend on Transient Mark mode.  It's the "active mark" state that
> depends on Transient Mark mode, in the sense that the mark doesn't
> automatically become active when Transient Mark mode is off and
> set-mark-command or push-mark is called.
>
> So I think a better documentation change would be to say that
> rectangle mark mode only works when the mark is active, and point to
> "Disabled Transient Mark" node of the manual for how to do that when
> Transient Mark mode is off.  This should probably be a separate
> paragraph, after the current text.

Yes, that's better, thank you.

Revised patch enclosed.

-- 
Sean Whitton
>From 6b7d5550ce7a5b72712730248f9d8f07f15e7483 Mon Sep 17 00:00:00 2001
From: Sean Whitton <[email-masked]>
Date: Mon, 27 Dec 2021 12:58:25 -0700
Subject: [PATCH v2] Improve rectangle-mark-mode documentation regarding mark
 activation

* doc/emacs/killing.texi: Describe how rectangle-mark-mode works when
Transient Mark mode is off.  Qualify discussion of
rectangle-exchange-point-and-mark to say that it cycles the four
corners only when the region is active.
* lisp/rect.el (rectangle-mark-mode): State that rectangle-mark-mode
does not activate the mark when Transient Mark mode is off.  Reword
sentence about how long the mode lasts to account for when Transient
Mark mode is off.
---
 doc/emacs/killing.texi | 16 +++++++++++-----
 lisp/rect.el           |  3 ++-
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/doc/emacs/killing.texi b/doc/emacs/killing.texi
index 375ac970d7..3815c0fef6 100644
--- a/doc/emacs/killing.texi
+++ b/doc/emacs/killing.texi
@@ -929,6 +929,11 @@ Rectangles
 rectangle.  @xref{Killing}.  The mode persists only as long as the
 region is active.
 
+The region-rectangle works only when the mark is active.  In
+particular, when Transient Mark mode is off (@pxref{Disabled Transient
+Mark}), in addition to typing @kbd{C-x @key{SPC}} you will need to
+activate the mark.
+
 Unlike the standard region, the region-rectangle can have its corners
 extended past the end of buffer, or inside stretches of white space
 that point normally cannot enter, like in the middle of a TAB
@@ -937,11 +942,12 @@ Rectangles
 @findex rectangle-exchange-point-and-mark
 @findex exchange-point-and-mark@r{, in rectangle-mark-mode}
 @kindex C-x C-x@r{, in rectangle-mark-mode}
-When the region is in rectangle-mark-mode, @kbd{C-x C-x} runs the
-command @code{rectangle-exchange-point-and-mark}, which cycles between
-the four corners of the region-rectangle.  This comes in handy if you
-want to modify the dimensions of the region-rectangle before invoking
-an operation on the marked text.
+When the region is active (@pxref{Mark}) and in rectangle-mark-mode,
+@kbd{C-x C-x} runs the command
+@code{rectangle-exchange-point-and-mark}, which cycles between the
+four corners of the region-rectangle.  This comes in handy if you want
+to modify the dimensions of the region-rectangle before invoking an
+operation on the marked text.
 
 @node CUA Bindings
 @section CUA Bindings
diff --git a/lisp/rect.el b/lisp/rect.el
index d288adfbaf..80f992e182 100644
--- a/lisp/rect.el
+++ b/lisp/rect.el
@@ -651,7 +651,8 @@ rectangle-mark-mode-map
 (define-minor-mode rectangle-mark-mode
   "Toggle the region as rectangular.
 
-Activates the region if needed.  Only lasts until the region is deactivated."
+Activates the region if it's inactive and Transient Mark mode is
+on.  Only lasts until the region is next deactivated."
   :lighter nil
   (rectangle--reset-crutches)
   (when rectangle-mark-mode
-- 
2.30.2