From xemacs-m  Thu May  1 02:40:15 1997
Received: from sicmail.epfl.ch (sicmail.epfl.ch [128.178.50.31])
	by xemacs.org (8.8.5/8.8.5) with SMTP id CAA27272
	for <xemacs-beta@xemacs.org>; Thu, 1 May 1997 02:40:01 -0500 (CDT)
Received: from lspsun16.epfl.ch by sicmail with SMTP (PP);
          Thu, 1 May 1997 09:25:00 +0200
Received: by lspsun16.epfl.ch (SMI-8.6/Epfl-4.9-c/MX) id JAA02122;
          Thu, 1 May 1997 09:31:33 +0200
To: Hrvoje Niksic <hniksic@srce.hr>
Cc: XEmacs Developers <xemacs-beta@xemacs.org>
Subject: Re: Fixing C-g; zmacs-region woes
References: <kigrafsk4p1.fsf@jagor.srce.hr>
X-Attribution: Oscar
X-Face: &f0TVPZirOQ$"C[5pZkDY(1~+M1p0&edTtJPL-*?u$b(vr<1m?~iZBqp2YoDS[IyxDHV<MN 
        x;/;<I]H;2OOZd:+cj^}L-,Hixp!@].>U~)KHl|Kpm"='5OF?vT]k_HQ1]|^}Pm>,;+]iJCt_-Y[S\ 
        EpwT);2R8#[4dt8~*}&#3$6xI4jNZM9lVHua'vIM[PEx*#cgxCVruf1zN0}
Mime-Version: 1.0 (generated by tm-edit 7.106)
Content-Type: text/plain; charset=US-ASCII
From: Oscar Figueiredo <Oscar.Figueiredo@di.epfl.ch>
Date: 01 May 1997 09:31:33 +0200
In-Reply-To: Hrvoje Niksic's message of 30 Apr 1997 15:42:18 +0200
Message-ID: <o97u3knsl62.fsf@lspsun16.epfl.ch>
Lines: 64
X-Mailer: Gnus v5.4.45/XEmacs 20.1(beta15)

>>>>> "Hrv" == Hrvoje Niksic <hniksic@srce.hr> writes:

  Hrv> [...] For example, I mark a region, and press `M-:'.  Then I remember I
  Hrv> didn't really want to press M-:, but M-x.  I press C-g, but I lose the
  Hrv> region.  I must press C-g one more time, and then press `C-x C-x' to
  Hrv> reactivate the region, followed by the desired M-x.

  Hrv> IMHO this is wrong.  The right thing is for M-g to deactivate the
  Hrv> region *if* the region is active in the current window.  So, in my
  Hrv> minibuffer, C-g would just signal QUIT without deactivating the
  Hrv> region.

That's the way Emacs 19.34 behaves.

  Hrv> Implementation of `keyboard-quit' is pretty straight-forward, so I
  Hrv> thought I might hack it:

  Hrv> (defun keyboard-quit ()
  Hrv>   "Docstring SNIPPED."
  Hrv>   (interactive)
  Hrv>   (if (and zmacs-regions (zmacs-deactivate-region))
  Hrv>       ;; pseudo-zmacs compatibility: don't beep if this ^G is simply
  Hrv>       ;; deactivating the region.  If it is inactive, beep.
  Hrv>       nil
  Hrv>     (signal 'quit nil)))

  Hrv> I'd like to change this into something like this:

  Hrv> (defun keyboard-quit ()
  Hrv>   "Docstring SNIPPED."
  Hrv>   (interactive)
  Hrv>   (if (and zmacs-regions (region-active-p (selected-window))
  Hrv>            (zmacs-deactivate-region))
  Hrv>       ;; pseudo-zmacs compatibility: don't beep if this ^G is simply
  Hrv>       ;; deactivating the region.  If it is inactive, beep.
  Hrv>       nil
  Hrv>     (signal 'quit nil)))

  Hrv> The only trouble is that `region-active-p' won't accept a WINDOW
  Hrv> argument.

Well in my opinion it shouldn't need to, (region-active-p) should implicitely
refer to the selected window. Besides I would not test for region-active in
keyboard-quit but rather in zmacs-deactivate-region :

(defun zmacs-deactivate-region ()
  "[...]"
  (if (region-active-p)
      nil

instead of 

(defun zmacs-deactivate-region ()
  "[...]"
  (if (not zmacs-region-active-p)
      nil

I tried to slightly modify zmacs-deactivate-region and keyboard-quit to achieve
the desired result but I found that switching windows has the *undesirable*
side-effect of deactivating the region in the window that is left. I suppose
this has to do with the select-window function but this leads directly into the
C code and I am not ready yet to enter that world :-) 

Oscar

