Subject: Re: bug#2760: CUA-like stuff spuriously enables transient-mark-mode.

From: Alan Mackenzie <[email-masked]>
Date: Tue, 24 Mar 2009 13:52:10 +0000

Hi, Stefan!

On Mon, Mar 23, 2009 at 08:46:22PM -0400, Stefan Monnier wrote:
> > 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.

> Can't reproduce it here (I tried the above, after replacing & with ?
> and I don't see any indication that transient-mark-mode is being set).

Sorry, my mistake.  Yes I did mean "?" in the binding, but as depicted
above, the bug doesn't happen.

Instead,

    (global-set-key [ ?\C-\M-m ] 'forward-char)

Now invoke forward-char with this binding + the shift key.  This enables
transient-mark-mode as a side effect.  This shouldn't happen.^H^H^H^H....

Correction: this can be disabled by nullifying the option
shift-select-mode - which isn't yet documented in the Emacs manual.  So I
withdraw my complaint, with apologies.

> > Why, why, why is this thing implemented by hard-coding in the command
> > loop, where it interferes with users' ability to chose key bindings?

> Where do you see it hardcoded in the command loop?

In Fcall_interactively, Lines 207 and 231, where it is interpreting the
interactive string:

      else if (*string == '^')
        {
          if (! NILP (Vshift_select_mode))
             call1 (Qhandle_shift_selection, Qnil);    <================
          /* Even if shift-select-mode is off, temporarily active
             regions could be set using the mouse, and should be
             deactivated.  */
          else if (CONSP (Vtransient_mark_mode)
                   && EQ (XCAR (Vtransient_mark_mode), Qonly))
            call1 (Qhandle_shift_selection, Qt);       <================
          string++;
        }
.

> > 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

> We'll cross this bridge when we get there.

>         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).