Subject: bug#6774: Cut and paste with C-w/mouse-2 not working?

From: Stefan Monnier <[email-masked]>
Date: Fri, 13 Aug 2010 12:38:06 +0200

>> I'm more worried about the semantics than about the performance impact.
>> Doing the "set PRIMARY" from C-w and friends is much easier and robust.
> How so?  Just moving the cursor because of a C-f involves a lot more X calls
> that taking ownership of the PRIMARY selection.  I don't understand how
> robustness is affected.

The issue with robustness (when talking about post-command-hook) doesn't
have much to do with heavy X calls (or performance), unless of course
those calls can hang.

The issue of robustness is that post-command-hook is not always run when
you want or need it.  E.g. you may want to run your hook if point is
moved by a process-filter (or you may want to run that hook when the
user is queried via y-or-n-p), but post-command-hook is not involved
there.  And OTOH post-command-hook may very well be run in the middle of
a command (if it reads from the minibuffer, for example).
These corner cases make post-command-hook brittle.

I think that for select-active-region to work the way you seem to want
it to work (i.e. auto-select as soon as the region is active and
non-empty), the "right hook" to use would be something like
a redisplay-hook (i.e. an active region is selected if/when it gets
displayed).  I would welcome such a hook, BTW, especially if it gets run
*before* redisplay.  Could be useful for reveal-mode and maybe also to
move the region-face handling to Elisp.

        Stefan