From xemacs-m  Tue Jun 24 05:24:10 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 FAA16577
	for <xemacs-beta@xemacs.org>; Tue, 24 Jun 1997 05:24:08 -0500 (CDT)
Received: (from hniksic@localhost)
          by jagor.srce.hr (8.8.5/8.8.4)
	  id MAA00759; Tue, 24 Jun 1997 12:24:08 +0200 (MET DST)
To: XEmacs Developers <xemacs-beta@xemacs.org>
Subject: [PATCH] `kill-region' fix
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 12:24:08 +0200
Message-ID: <kig7mfk70zb.fsf@jagor.srce.hr>
Lines: 46
X-Mailer: Gnus v5.4.59/XEmacs 20.3(beta8) - "Copenhagen"

As you may remember, `kill-region' doesn't work correctly with
read-only extents preceding the region, if beg > end.  To repeat, try
pressing M-backspace in an editable field (in Customize, for
instance; very annoying).

My last kill-region fix has been backed out because it created
unwanted side-effects.  Furthermore, I have discovered an infloop in
happening when `buffer-undo-list' is nil.

This patch fixes both problems:

--- lisp/prim/simple.el.orig	Tue Jun 24 12:12:42 1997
+++ lisp/prim/simple.el	Tue Jun 24 12:18:17 1997
@@ -1168,7 +1168,7 @@
    ;; just isn't aware of this.  However, there's no harm in putting
    ;; the region's text in the kill ring, anyway.
    ((or (and buffer-read-only (not inhibit-read-only))
-	(text-property-not-all beg end 'read-only nil))
+	(text-property-not-all (min beg end) (max beg end) 'read-only nil))
    ;; This is redundant.
    ;; (if verbose (message "Copying %d characters"
    ;;			 (- (max beg end) (min beg end))))
@@ -1195,11 +1195,13 @@
       ;; Search back in buffer-undo-list for this string,
       ;; in case a change hook made property changes.
       (setq tail buffer-undo-list)
-      (while (not (stringp (car-safe (car-safe tail)))) ; XEmacs
-	(setq tail (cdr tail)))
+      (while (and tail
+		  (not (stringp (car-safe (car-safe tail))))) ; XEmacs
+	(pop tail))
       ;; Take the same string recorded for undo
       ;; and put it in the kill-ring.
-      (kill-new (car (car tail)))))
+      (and tail
+	   (kill-new (car (car tail))))))
 
    (t
     ;; if undo is not kept, grab the string then delete it (which won't


-- 
Hrvoje Niksic <hniksic@srce.hr> | Student at FER Zagreb, Croatia
--------------------------------+--------------------------------
Then...  his face does a complete change of expression.  It goes from
a "Vengeance is mine" expression, to a "What the fuck" blank look.

