From xemacs-m  Mon Jul  7 23:32:02 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 XAA16326
	for <xemacs-beta@xemacs.org>; Mon, 7 Jul 1997 23:32:01 -0500 (CDT)
Received: (from hniksic@localhost)
          by jagor.srce.hr (8.8.5/8.8.4)
	  id GAA22218; Tue, 8 Jul 1997 06:32:02 +0200 (MET DST)
To: XEmacs Developers <xemacs-beta@xemacs.org>
Subject: [PATCH] `buffer-substring-no-properties' (was: dabbrev inserting read-only)
References: <87soxq2odf.fsf@bittersweet.inetarena.com>
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: 08 Jul 1997 06:32:02 +0200
In-Reply-To: karlheg+xemacs@inetarena.com's message of "07 Jul 1997 20:50:52 -0700"
Message-ID: <kigpvsukvul.fsf@jagor.srce.hr>
Lines: 47
X-Mailer: Gnus v5.4.59/XEmacs 20.3(beta11) - "Stockholm"

karlheg+xemacs@inetarena.com (Karl M. Hegbloom) writes:

> 	* packages/dabbrev.el: replace `buffer-substring' with
> 	`buffer-substring-no-properties' so that unwanted text
> 	properties (like read-only) are stripped from inserted
> 	dabbrev expansions.

I agree, heartily.  I have been bitten more than once by dabbrev
importing text `read-only' text property.  For things to be worse, I
could not even remove the text, because read-only extents cannot be
deleted, even as a whole.  The only thing I was able to do was:

(map-extents (lambda (ext ignore) (delete-extent ext) nil))

Now, that's what I'd call intuitive!


P.S.
The `buffer-substring-no-properties' function is much too pervasive -- 
it kills off *all* the extents, instead the text properties.  This was 
a necessity because in previous XEmacs versions the
`set-text-properties' function didn't work.  This patch will fix
things back to normal:

--- lisp/prim/subr.el.orig	Tue Jul  8 06:28:58 1997
+++ lisp/prim/subr.el	Tue Jul  8 06:28:59 1997
@@ -519,11 +519,9 @@
 ;;;; Miscellanea.
 
 (defun buffer-substring-no-properties (beg end)
-  "Return the text from BEG to END, without extents, as a string."
+  "Return the text from BEG to END, without text properties, as a string."
   (let ((string (buffer-substring beg end)))
-    (map-extents (lambda (ext &rest junk)
-		   (delete-extent ext))
-		 string)
+    (set-text-properties 0 (length string) nil string)
     string))
 
 (defun ignore (&rest ignore)


-- 
Hrvoje Niksic <hniksic@srce.hr> | Student at FER Zagreb, Croatia
--------------------------------+--------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it."                                    -- Donald Knuth

