From xemacs-m  Tue Jun 24 14:12:41 1997
Received: from jagor.srce.hr (hniksic@jagor.srce.hr [161.53.2.130])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id OAA23717
	for <xemacs-beta@xemacs.org>; Tue, 24 Jun 1997 14:12:40 -0500 (CDT)
Received: (from hniksic@localhost)
          by jagor.srce.hr (8.8.5/8.8.4)
	  id VAA02176; Tue, 24 Jun 1997 21:12:40 +0200 (MET DST)
To: XEmacs Developers <xemacs-beta@xemacs.org>
Subject: [PATCH] Trigger-happy zmacs-deactivation fixed
X-Attribution: Hrv
X-Face: Mie8:rOV<\c/~z{s.X4A{!?vY7{drJ([U]0O=W/<W*SMo/Mv:58:*_y~ki>xDi&N7XG
        KV^$k0m3Oe/)'e%3=$PCR&3ITUXH,cK>]bci&<qQ>Ff%x_>1`T(+M2Gg/fgndU%k*ft
        [(7._6e0n-V%|%'[c|q:;}td$#INd+;?!-V=c8Pqf}3J
From: Hrvoje Niksic <hniksic@srce.hr>
Date: 24 Jun 1997 21:12:39 +0200
Message-ID: <kigu3inx1aw.fsf@jagor.srce.hr>
Lines: 73
X-Mailer: Gnus v5.4.59/XEmacs 20.3(beta8) - "Copenhagen"

How often have you marked a region and pressed `M-x', and then
remembered that you really wanted to press `M-:'?  Or `M-!'?  Or, you
pressed `M-|', but you wanted to press `C-u M-|'?

In all of these cases, you press C-g to exit the minibuffer, but the
stupid keybinding kills the region instead.  Then you have to press
C-g a *second* time, to exit the minibuffer, then press `C-x C-x' (or
`C-M-z') to reactivate the region, and issue the desired command.
Annoying as hell.

The following patch makes C-g behave like this:

- if the region is active *in the current buffer*, deactivate region;

- else, signal QUIT.

Also, the errors no longer deactivate regions by default -- you have
to press C-g.  It was very annoying that a slight mistake like
pressing `M-: RET' would destroy the region.

I think this behaviour is much saner than what it was before, and
various people asked for this change in the past.  What do you think?

--- lisp/prim/cmdloop.el.orig	Tue Jun 24 20:43:54 1997
+++ lisp/prim/cmdloop.el	Tue Jun 24 20:50:20 1997
@@ -58,10 +58,11 @@
 If this character is typed while lisp code is executing, it will be treated
  as an interrupt.
 If this character is typed at top-level, this simply beeps.
-If `zmacs-regions' is true, and the zmacs region is active, then this
- key deactivates the region without beeping or signalling."
+If `zmacs-regions' is true, and the zmacs region is active in this buffer,
+then this key deactivates the region without beeping or signalling."
   (interactive)
-  (if (and zmacs-regions (zmacs-deactivate-region))
+  (if (and (region-active-p)
+	   (eq (current-buffer) (zmacs-region-buffer)))
       ;; pseudo-zmacs compatibility: don't beep if this ^G is simply
       ;; deactivating the region.  If it is inactive, beep.
       nil
@@ -104,7 +105,7 @@
     (setq standard-output t)
     (setq standard-input t)
     (setq executing-kbd-macro nil)
-    (zmacs-deactivate-region)
+;    (zmacs-deactivate-region)
     (discard-input)
 
     (setq last-error error-object)
--- lisp/prim/minibuf.el.orig	Tue Jun 24 20:49:30 1997
+++ lisp/prim/minibuf.el	Tue Jun 24 20:50:15 1997
@@ -230,10 +230,11 @@
 
 (defun minibuffer-keyboard-quit ()
   "Abort recursive edit.
-If `zmacs-regions' is true, and the zmacs region is active, then this
-key deactivates the region without beeping."
+If `zmacs-regions' is true, and the zmacs region is active in this buffer,
+then this key deactivates the region without beeping."
   (interactive)
-  (if (and zmacs-regions (zmacs-deactivate-region))
+  (if (and (region-active-p)
+	   (eq (current-buffer) (zmacs-region-buffer)))
       ;; pseudo-zmacs compatibility: don't beep if this ^G is simply
       ;; deactivating the region.  If it is inactive, beep.
       nil


-- 
Hrvoje Niksic <hniksic@srce.hr> | Student at FER Zagreb, Croatia
--------------------------------+--------------------------------
* Vi is the God of editors.
* Emacs is the editor of Gods.

