Subject: bug#66780: [PATCH] Improve rectangle-mark-mode when transient-mark-mode is off

From: Jens Schmidt <[email-masked]>
Date: Sat, 28 Oct 2023 12:50:48 +0200

Eli Zaretskii <[email-masked]> writes:

>> Date: Fri, 27 Oct 2023 22:31:24 +0200
>> From:  Jens Schmidt via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <[email-masked]>
>>
>> I have attempted to improve the situation by providing documentation
>> (fix A) in a patch on emacs-29, and some minor code fixes (B and C) in a
>> patch on emacs-master.  That latter patch still has a placeholder
>> "bug#XXXXX" which needs to be updated once I have a bug number.
>
> Do we expect people to use rectangle-mark-mode with
> transient-mark-mode turned off?

Sean and me make two already.  More seriously, I use shift-select-mode
with transient-mark-mode turned off, because I'd like to have the region
inactive as much as possible.

And I always have been looking for an option to more easily operate on
rectangles at EOL, like in the following example:

              vvv add another column with "foo" here
  foo
  foo bar
  foo bar baz

rectangle-mark-mode seems to fill that gap nicely, in particular, since
it could be used with shift-select-mode once the interactive specifiers
have been amended accordingly.  In the above example, I move to the last
line, then: C-e, C-x <SPC>, C-3 S-<up>, C-x r t, all the while staying
in my usual shift-select work flow.

> The description of the behavior in that case is complicated and
> confusing, and I wonder whether we should have it in the manual.  We
> could just say that the behavior is slightly different, and that we
> don't recommend turning off transient-mark-mode if the user wants to
> use rectangle-mark-mode.

Agreed in general but see above for a use-case where the combination
seems helpful.

Another option would have been to turn off the confusing bits of RMM
when *permanent* TMM is off.  I would have preferred that, actually: A
rectangle-mark-mode that *really* only shows the region-rectangle when
permanent TMM is off but leaves all other functionality (kill, yank, C-x
C-x) unchanged.  In that case a conditional minor mode lighter would not
be neccessary, either.

What do you think about that option?

>> * Fix B: Use a Minor Mode Lighter
>>
>> With TMM off and RMM on, the most important indicator of RMM (the
>> region-rectangle) is not visible.  And since RMM's minor mode lighter is
>> nil, one has no visible feedback of it still being active.  That can be
>> surprising since some of its features are still active as described
>> above.
>
> Again, not sure indicating this combination is worth our while,
> especially since the real estate on the mode line is already too
> scarce, so much so that in many windows important information at the
> end of the mode line is pushed beyond the limits.

Agreed on the real estate, but the information would be displayed only
in very specific circumstances, for very few (?) users, and only for a
very short time, since that minor mode has a short lifetime.  But WHEN
it is displayed, it could save confusion and inadvertent edits.

> Why do you think it's important to have this combination prominently
> documented and indicated at run time?  Do we have any evidence that it
> is used frequently enough to justify these measures?

No poll results available.  But I guess that users coming from other
editors could prefer

  transient-mark-mode: off
  shift-select-mode:   on

since this is closer to their previous experience, where the region
always deactivates itself as soon as you move the (unshifted) cursor.

Finally, do you also have any objections on fix C, adding the "^"
markers to the interactive specs of the movement commands?  Or would
that bit be OK?