From xemacs-m  Tue Jul  8 21:09:33 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 VAA27534
	for <xemacs-beta@xemacs.org>; Tue, 8 Jul 1997 21:09:31 -0500 (CDT)
Received: (from hniksic@localhost)
	by jagor.srce.hr (8.8.6/8.8.6) id EAA26115;
	Wed, 9 Jul 1997 04:09:27 +0200 (MET DST)
To: XEmacs Developers <xemacs-beta@xemacs.org>
Subject: Non-symbol extent properties
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: 09 Jul 1997 04:09:27 +0200
Message-ID: <kiglo3h7z8o.fsf@jagor.srce.hr>
Lines: 164
X-Mailer: Gnus v5.4.59/XEmacs 20.3(beta11) - "Stockholm"

The text-properties manual in Lispref sez:

       Each property has a name and a value.  Both of these can be any Lisp
    object, but the name is normally a symbol.  The usual way to access the
    property list is to specify a name and ask what value corresponds to it.

However, this is not true in XEmacs, since extent properties can only
have symbol properties.

But, when you think about it, it is really trivial to implement,
because FSF, although it allows the properties to be non-symbols, it
*still* matches them with EQ (so it's *not* a lax-plist).  Thus, I
find that the following patch seems to fix the situation seamlessly,
and without hidden gotchas.  The extent code still uses EQ to compare
props, and that is fine.

The only gotcha I can think of is the code that might simply assume
that all extent properties are symbols -- like the code in
`print_extent_1' does.

Are there any other hidden gotchas that I'm missing?

1997-07-09  Hrvoje Niksic  <hniksic@srce.hr>

	* extents.c: Allow non-symbol properties of extents.

--- src/extents.c.orig	Wed Jul  9 03:40:20 1997
+++ src/extents.c	Wed Jul  9 04:06:11 1997
@@ -2979,9 +2979,17 @@
 
   for (; !NILP (tail); tail = Fcdr (Fcdr (tail)))
     {
-      struct Lisp_String *k = XSYMBOL (XCAR (tail))->name;
+      struct Lisp_String *k;
       Lisp_Object v = XCAR (XCDR (tail));
       if (NILP (v)) continue;
+      if (!SYMBOLP (XCAR (tail)))
+	{
+	  /* ### Fix this! */
+	  strcpy (bp, "non-symbol ");
+	  bp += 11;
+	  continue;
+	}
+      k = XSYMBOL (XCAR (tail))->name;
       memcpy (bp, (char *) string_data (k), string_length (k));
       bp += string_length (k);
       *bp++ = ' ';
@@ -4049,7 +4057,6 @@
 
   if (!NILP (property))
     {
-      CHECK_SYMBOL (property);
       if (!NILP (value))
 	value =	canonicalize_extent_property (property, value);
     }
@@ -4194,7 +4201,6 @@
 
   if (!NILP (property))
     {
-      CHECK_SYMBOL (property);
       if (!NILP (value))
 	value =	canonicalize_extent_property (property, value);
     }
@@ -4388,7 +4394,6 @@
 
   object = decode_buffer_or_string (object);
   position = get_buffer_or_string_pos_byte (object, pos, GB_NO_ERROR_IF_BAD);
-  CHECK_SYMBOL (property);
   if (NILP (before))
     before_extent = 0;
   else
@@ -5161,7 +5166,6 @@
 {
   /* This function can GC if property is `keymap' */
   EXTENT e = decode_extent (extent, 0);
-  CHECK_SYMBOL (property);
 
   if (EQ (property, Qread_only))
     set_extent_read_only (e, value);
@@ -5243,7 +5247,6 @@
        (extent, property, defalt))
 {
   EXTENT e = decode_extent (extent, 0);
-  CHECK_SYMBOL (property);
 
   if      (EQ (property, Qdetached))
     return (extent_detached_p (e) ? Qt : Qnil);
@@ -5860,7 +5863,6 @@
 
   object = decode_buffer_or_string (object);
   position = get_buffer_or_string_pos_byte (object, pos, GB_NO_ERROR_IF_BAD);
-  CHECK_SYMBOL (prop);
 
   /* We canonicalize the start/end-open/closed properties to the
      non-default version -- "adding" the default property really
@@ -6244,7 +6246,6 @@
 
   object = decode_buffer_or_string (object);
   get_buffer_or_string_range_byte (object, start, end, &s, &e, 0);
-  CHECK_SYMBOL (prop);
   put_text_prop (s, e, object, prop, value, 1);
   return prop;
 }
@@ -6265,7 +6266,6 @@
 
   object = decode_buffer_or_string (object);
   get_buffer_or_string_range_byte (object, start, end, &s, &e, 0);
-  CHECK_SYMBOL (prop);
   put_text_prop (s, e, object, prop, value, 0);
   return prop;
 }
@@ -6290,7 +6290,6 @@
     {
       Lisp_Object prop = XCAR (props);
       Lisp_Object value = Fcar (XCDR (props));
-      CHECK_SYMBOL (prop);
       changed |= put_text_prop (s, e, object, prop, value, 1);
     }
   return (changed ? Qt : Qnil);
@@ -6319,7 +6318,6 @@
     {
       Lisp_Object prop = XCAR (props);
       Lisp_Object value = Fcar (XCDR (props));
-      CHECK_SYMBOL (prop);
       changed |= put_text_prop (s, e, object, prop, value, 0);
     }
   return (changed ? Qt : Qnil);
@@ -6344,7 +6342,6 @@
   for (; !NILP (props); props = Fcdr (Fcdr (props)))
     {
       Lisp_Object prop = XCAR (props);
-      CHECK_SYMBOL (prop);
       changed |= put_text_prop (s, e, object, prop, Qnil, 1);
     }
   return (changed ? Qt : Qnil);
@@ -6428,7 +6425,6 @@
       blim = get_buffer_or_string_pos_char (object, limit, 0);
       limit_was_nil = 0;
     }
-  CHECK_SYMBOL (prop);
 
   extent = Fextent_at (make_int (bpos), object, prop, Qnil, Qnil);
   if (!NILP (extent))
@@ -6496,8 +6492,6 @@
       blim = get_buffer_or_string_pos_char (object, limit, 0);
       limit_was_nil = 0;
     }
-
-  CHECK_SYMBOL (prop);
 
   /* extent-at refers to the character AFTER bpos, but we want the
      character before bpos.  Thus the - 1.  extent-at simply


P.S.
Oh, and BTW: print_extent_1 is totally lame (with or without the
change).  If a printable representation of an extent grows out of 256
bytes, bye bye.

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

