Subject: Re: EMACS vs. Windows GUI: Region highlight confusion

From: "Kim F. Storm" <[email-masked]>
Date: Mon, 19 Aug 1996 10:11:39 +0200 (MET DST)

>>>>> "KFS" == Kim F Storm <[email-masked]> writes:

   KFS> In windows, I think most applications behave as follows:

   KFS> 	When a piece of text is highlighted in a window (typically
   KFS> 	selected with the mouse) then pressing DELETE will delete the
   KFS> 	highlighted text, and entering other text will replace the
   KFS> 	highlighted text.

   From: Jack Vinson <[email-masked]>
   Date: 16 Aug 1996 09:27:25 -0400

   What happens to Unix users who are not familiar with Windows?  If you want
   to cut a region that you've marked with the mouse, you may as well continue
   using the mouse:  Mark a region and then double click the left mouse button
   (mouse 3).  Actually, just double clicking mouse 3 will kill the region
   between the point and the mouse cursor.

I don't see how adding the ability to delete the selected region using
DELETE can make such a difference to non-Windows (and non-DOS) users;
since the temporary highlighting of the mouse region is a fairly new
feature (19.31), there is really little previous experience to break...

   From: [email-masked]
   Date: Fri, 16 Aug 1996 13:19:01 -0700

   ... (pc-selection-mode) ... gives me a CUA type selection
   mechanism. Shift arrows to select, then typing replaces, DEL
   deletes, etc.

Yes, there are packages (such as pc-select.el and delsel.el) which
will change the overall functionality of the region in emacs towards a
more DOS/Windows like manner; this may be good for those who would
like that.

   Date: Fri, 16 Aug 1996 12:14:34 -0700
   From: Kin Cho <[email-masked]>

   KFS> I'm really not interested in having normal text replacing the
   KFS> temporarily highlighted region, so it is only the DELETE function I'm
   KFS> interested in.

   If emacs is going to imitate the Windows behavior, either it should
   do so completely or not at all.

Well, as [email-masked] has pointed out, there are packages which
will make the region in emacs work more like ordinary DOS and Windows
editors (and other GUI applications) - for all editing.

But that is not my purpose here!

What I want is just to make the temporary mouse region highlight
(which was introducted in 19.31) *less confusing* to the casual
windows user - without making severe changes to the way emacs works as
such. 

Making DELETE delete the selected region doesn't seem to be a
change which will impact general emacs use in a negative way - while
making newly typed text replace the region definitely will.

And I would think some users would like the new functionality; hitting
DELETE to delete the just selected text may sometimes be easier than
having to double-click mouse-3 at the same location where you released
mouse-1.

   Date: Fri, 16 Aug 1996 13:31:17 -0400
   From: Richard Stallman <[email-masked]>

   I guess it is ok to make this the default.

I still think it is.

--
Kim F. Storm <[email-masked]>

---

From: [email-masked]
Date: Fri, 16 Aug 1996 13:19:01 -0700

>>>>> "Kin" == Kin Cho <[email-masked]> writes:

    >> I'm really not interested in having normal text replacing the
    >> temporarily highlighted region, so it is only the DELETE
    >> function I'm interested in.

    Kin> If emacs is going to imitate the Windows behavior, either it
    Kin> should do so completely or not at all.

    Kin> -kin

Placing:

(pc-selection-mode) 

in my .emacs gives me a CUA type selection mechanism. Shift arrows to
select, then typing replaces, DEL deletes, etc. There was another mode
someone pointed out that does this for any selection (i.e. mouse,
etc), but I don't remember what it was...

rjf

--
"...fame is a cancer and ego its seed...",Toad the Wet Sprocket
For pgp key, finger [email-masked]

---

From: Jack Vinson <[email-masked]>
Date: 16 Aug 1996 09:27:25 -0400

[snip idea for making this work in emacs]

-- 
Jack Vinson                       [email-masked]
"I Spit on Your Grave"            -- double feature at the drive-in as seen
"I Thumb Through Your Magazines"     from the Qwik-E mart

---

From: "Kim F. Storm" <[email-masked]>
Date: Fri, 16 Aug 1996 11:22:30 +0200 (MET DST)

In windows, I think most applications behave as follows:

	When a piece of text is highlighted in a window (typically
	selected with the mouse) then pressing DELETE will delete the
	highlighted text, and entering other text will replace the
	highlighted text.

Prior to emacs 19.31, there were normally no region highlighting
(unless you had transient-mark-mode turned on, and in that case you
could use the delsel.el package to more or less get the above
behaviour).

Since emacs 19.31, selecting a region with the mouse now leaves the
region highlighted (without setting transient-mark-mode) until the
next input event occurs (e.g. hitting a key).

Now, if I select a region with the mouse, and then hit DELETE, the
highlight disappears, but it is the character which FOLLOWS the region
that is deleted!  If one is not careful, then the removal of the
highlight may easily be mentally interpreted as a deletion of the text
as well - especially because this is normal behaviour for other
windows applications!

The delsel.el package does not handle this case since it requires the
transient-mark-mode to be active - and I do not like that!

Looking at the code, the temporarily highlighting of the region
selected by the mouse is done in the mouse-show-mark function; it
simply reads the next event itself, then removes the highlight and
pushes the event back on the "unread event" queue.

So the delete-char command bound to the DELETE key is actually
executed after the region highlight has been removed; so just writing
another handler for the DELETE key (delete-char-or-mouse-region)
doesn't seem to be possible (or at least hard to do)?!

I'm really not interested in having normal text replacing the
temporarily highlighted region, so it is only the DELETE function I'm
interested in.

When 19.31 was released, I suggested to RMS to handle DELETE as a
special case directly in mouse-show-mark (mouse-drag-region in 19.31),
but he didn't want to do that (I do admit, it was a rather ugly hack).

I have since made the feature configurable via a list of keys which
should delete the highlighted mouse region and adapted my code to
mouse.el from 19.33; the updated mouse-show-mark function is attached
below.

I would like to hear whether other nt-emacs users have any opinions on
this subject, and whether you would like this to be a standard emacs
feature.

----- put this in mouse.el or in your .emacs ------

(defvar mouse-region-delete-keys '([delete] [backspace])
  "List of keys which shall cause the mouse region to be deleted.")

(defun mouse-show-mark ()
  (if transient-mark-mode
      (if window-system
	  (delete-overlay mouse-drag-overlay))
    (if window-system
	(let ((inhibit-quit t)
	      (echo-keystrokes 0)
	      event events key)
	  (move-overlay mouse-drag-overlay (point) (mark t))
	  (while (progn (setq event (read-event))
			(setq events (append events (list event)))
			(setq key (apply 'vector events))
			(and (memq 'down (event-modifiers event))
			     (not (key-binding key))
			     (not (member key mouse-region-delete-keys))
			     (not (mouse-undouble-last-event events)))))
	  (if (member key mouse-region-delete-keys)
	      (delete-region (overlay-start mouse-drag-overlay)
			     (overlay-end mouse-drag-overlay))
	    (setq unread-command-events
		  (nconc events unread-command-events)))
	  (setq quit-flag nil)
	  (delete-overlay mouse-drag-overlay))
      (save-excursion
       (goto-char (mark t))
       (sit-for 1)))))