Subject: CUA-like stuff spuriously enables transient-mark-mode.

From: Alan Mackenzie <[email-masked]>
Date: Mon, 23 Mar 2009 22:37:03 +0000

Hi, Richard, Eli and Emacs!

Start the CVS head "emacs -Q", and evaluate this:

    (global-set-key [ &\C-\M-\S-m ] 'forward-char)
    (transient-mark-mode -1)

In some buffer, invoke 'forward-char by the above binding.  This enables
transient-mark-mode as a side effect.  This shouldn't happen.  It happens
both in a Linux Virtual terminal (with the requisite enhancements to the
keyboard handling) and in X-Windows.

ANALYSIS:
---------
The "^" in the interactive string causes `handle-shift-selection' to be
invoked by the command loop.  The function and friends abuse the user
option variable `transient-mark-mode' by additionally storing some sort
of state in it.  h-s-s writes the value '(only) into the variable
transient-mark-mode, thus enabling the mode.  A sensible fix would surely
involve leaving `transient-mark-mode' severely alone (only the user
should set this) and creating another variable (or several) to hold the
state currently mashed into t-m-m.

COMMENT:
--------
It is now no longer true that "But Emacs does not assign meanings to keys
directly" (Emacs manual, page "Commands") - Emacs directly assigns a
meaning to the shift key.  This is surely a Bad Thing.

Why, why, why is this thing implemented by hard-coding in the command
loop, where it interferes with users' ability to chose key bindings?
Surely this feature with the shift key should have been implemented by
defining defuns such as `forward-char-with-marking', and putting these
commands in some suitable keymap?  OK, it's more work, but not _that_
much more.

It's practically 100% certain that somebody, somewhere, will want to use
the hyper- or alt- keys instead of <shift> to get this visible region
feature, or possibly might want to use separate bindings entirely.

It's near 100% certain that somebody, somewhere, perhaps with a name like
Xah Lee, will want to use C-f as "find" (i.e. bind it to
`isearch-forward') and use C-S-f for `forward-char'.

-- 
Alan Mackenzie (Nuremberg, Germany).