Subject: bug#10056: 24.0.91; `copy-to-register' does not deactivate the mark

From: Alan Mackenzie <[email-masked]>
Date: Fri, 3 Aug 2012 21:47:29 +0000

Hi, Dani.

On Thu, Aug 02, 2012 at 12:07:06AM +0200, Dani Moncayo wrote:
> >> > As for c-indent-line-or-region, I have no opinion on that at all.

> >> (I'm CC-ing Alan.  Hopefully he has an opinion) This is the current
> >> behavior I observe:
> >> * If the command has to adjust the indentation of some line(s) in the
> >> region, the mark is deactivated at the end of the command.
> >> * Else, the mark is not deactivated.

> >> This behavior is definitely annoying for me: when I mark some fragment
> >> of code and type TAB, what I want is that Emacs revise the indentation
> >> of code, and correct it if necessary, but in any case, I don't want
> >> the mark to remain active.

> > Have you looked at the code for c-i-l-o-region? At a quick glance, I
> > can't see where the distinction is made between indentation adjusted and
> > not adjusted.  I don't actually use transient-mark-mode myself, so this
> > hasn't annoyed me one way or the other.

> > Is the distinction there for a reason, or did it just get there by
> > accident?  The defun is only several (as opposed to many) years old, so
> > the evidence should still be available in the bzr repo.

> I'm sorry, I (still) don't have enough knowledge of Emacs to delve
> into such questions.

> I reported this bug as a mere user, hoping that you (the maintainers),
> if agree with my reasoning, make the suitable changes to the program.

Sorry, misunderstanding on my part there.

> In the case at hand, what I reported is quite simple, I think: from
> "emacs -Q" (transient mark mode on) visit some C file, select some
> fragment of code and type TAB.

> Hopefully you'll see the same behavior as me:
> * If the code in the region was already well indented, nothing happens
> and the mark remains active.
> * Else, the code is indented and the mark is deactivated.

Yes, I see this.

> What I say is that the mark should be deactivated _always_ at the end
> of the command, because the "transient" operation (revise the
> indentation of those lines) is done.

> This is so obvious to me that I'm surprised of seeing you so
> hesitant...  but well, you decide :)

The hesitancy comes from long experience of Emacs; things which are so
obviously wrong to some are obviously the RT to others.  I was wondering
if this behaviour, strange though it seems to both of us, might have been
programmed deliberately.

In this case, there seems to be some bug at the lower levels of Emacs.
There is nothing in CC Mode I can find to explain this strange behaviour.
According to the elisp manual, the normal way of deactivating a region
when transient mark mode is enabled is to set the variable
`deactivate-mark', which instructs the command loop to do the business.

CC Mode doesn't set `deactivate-mark' at all.  Maybe some primitive does.
I don't really know transient-mark-mode.  Yidong, have you any
suggestions here?

> -- 
> Dani Moncayo

-- 
Alan Mackenzie (Nuremberg, Germany).