From xemacs-m  Sat May 31 20:09:51 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 UAA17204
	for <xemacs-beta@xemacs.org>; Sat, 31 May 1997 20:09:40 -0500 (CDT)
Received: (from hniksic@localhost)
          by jagor.srce.hr (8.8.5/8.8.4)
	  id DAA02844; Sun, 1 Jun 1997 03:09:14 +0200 (MET DST)
To: XEmacs Developers <xemacs-beta@xemacs.org>
Subject: [patch] `kill-region' fails on reversed arguments
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
Tomato: Plaid
From: Hrvoje Niksic <hniksic@srce.hr>
Date: 01 Jun 1997 03:09:14 +0200
Message-ID: <kign2pbp1s5.fsf@jagor.srce.hr>
Lines: 44
X-Mailer: Gnus v5.4.52/XEmacs 20.2

When `kill-region' checks for read-only buffer, it calls (among other
things) `text-properties-any'.  This doesn't behave well when
beg > end, and the function thinks a portion of the buffer is
read-only.

To repeat this, try to backward-kill the first word of a widget
editable field, using M-DEL.  It fails.

This patch fixes things up by swapping beg and end if necessary.  It
simplifies the whole function (hopefully without breaking anything):

--- simple.el.orig	Sun Jun  1 02:59:47 1997
+++ simple.el	Sun Jun  1 03:03:03 1997
@@ -1117,11 +1117,10 @@
   (or (and beg end) (if zmacs-regions ;; rewritten for I18N3 snarfing
 			(error "The region is not active now")
 		      (error "The mark is not set now")))
+  (if (> beg end) (setq beg (prog1 end (setq end beg))))
   (if verbose (if buffer-read-only
-		  (message "Copying %d characters"
-		       (- (max beg end) (min beg end)))
-		  (message "Killing %d characters"
-		       (- (max beg end) (min beg end)))))
+		  (message "Copying %d characters" (- end beg))
+		  (message "Killing %d characters" (- end beg))))
   (cond
 
    ;; I don't like this large change in behavior -- jwz
@@ -1151,7 +1150,7 @@
 	     (= beg end)))
     ;; Don't let the undo list be truncated before we can even access it.
     ;; FSF calls this `undo-strong-limit'
-    (let ((undo-high-threshold (+ (- (max beg end) (min beg end)) 100))
+    (let ((undo-high-threshold (+ (- end beg) 100))
 	  ;(old-list buffer-undo-list)
 	  tail)
       (delete-region beg end)


-- 
Hrvoje Niksic <hniksic@srce.hr> | Student at FER Zagreb, Croatia
--------------------------------+--------------------------------
Thou Who might be our Father Who perhaps may be in Heaven...
                                                -- Roger Zelazny

