comparison src/extents.c @ 272:c5d627a313b1 r21-0b34

Import from CVS: tag r21-0b34
author cvs
date Mon, 13 Aug 2007 10:28:48 +0200
parents 157b30c96d03
children 6330739388db
comparison
equal deleted inserted replaced
271:c7b7086b0a39 272:c5d627a313b1
222 #include "faces.h" 222 #include "faces.h"
223 #include "frame.h" 223 #include "frame.h"
224 #include "glyphs.h" 224 #include "glyphs.h"
225 #include "hash.h" 225 #include "hash.h"
226 #include "insdel.h" 226 #include "insdel.h"
227 #include "keymap.h"
227 #include "opaque.h" 228 #include "opaque.h"
228 #include "process.h" 229 #include "process.h"
229 #include "redisplay.h" 230 #include "redisplay.h"
230 231
231 /* ------------------------------- */ 232 /* ------------------------------- */
347 /* ------------------------------- */ 348 /* ------------------------------- */
348 /* auxiliary extent structure */ 349 /* auxiliary extent structure */
349 /* ------------------------------- */ 350 /* ------------------------------- */
350 351
351 struct extent_auxiliary extent_auxiliary_defaults; 352 struct extent_auxiliary extent_auxiliary_defaults;
352
353 MAC_DEFINE (EXTENT, MTancestor_extent)
354 MAC_DEFINE (EXTENT, MTaux_extent)
355 MAC_DEFINE (EXTENT, MTplist_extent)
356 MAC_DEFINE (EXTENT, MTensure_extent)
357 MAC_DEFINE (EXTENT, MTset_extent)
358 353
359 /* ------------------------------- */ 354 /* ------------------------------- */
360 /* buffer-extent primitives */ 355 /* buffer-extent primitives */
361 /* ------------------------------- */ 356 /* ------------------------------- */
362 357
468 Lisp_Object Vextent_face_reverse_memoize_hash_table; 463 Lisp_Object Vextent_face_reverse_memoize_hash_table;
469 Lisp_Object Vextent_face_reusable_list; 464 Lisp_Object Vextent_face_reusable_list;
470 /* FSFmacs bogosity */ 465 /* FSFmacs bogosity */
471 Lisp_Object Vdefault_text_properties; 466 Lisp_Object Vdefault_text_properties;
472 467
468
469 EXFUN (Fextent_properties, 1);
470 EXFUN (Fset_extent_property, 3);
471
473 472
474 /************************************************************************/ 473 /************************************************************************/
475 /* Generalized gap array */ 474 /* Generalized gap array */
476 /************************************************************************/ 475 /************************************************************************/
477 476
730 { 729 {
731 Gap_Array *ga = endp ? el->end : el->start; 730 Gap_Array *ga = endp ? el->end : el->start;
732 int left = 0, right = GAP_ARRAY_NUM_ELS (ga); 731 int left = 0, right = GAP_ARRAY_NUM_ELS (ga);
733 int oldfoundpos, foundpos; 732 int oldfoundpos, foundpos;
734 int found; 733 int found;
735 EXTENT e;
736 734
737 while (left != right) 735 while (left != right)
738 { 736 {
739 /* RIGHT might not point to a valid extent (i.e. it's at the end 737 /* RIGHT might not point to a valid extent (i.e. it's at the end
740 of the list), so NEWPOS must round down. */ 738 of the list), so NEWPOS must round down. */
741 unsigned int newpos = (left + right) >> 1; 739 unsigned int newpos = (left + right) >> 1;
742 e = EXTENT_GAP_ARRAY_AT (ga, newpos); 740 EXTENT e = EXTENT_GAP_ARRAY_AT (ga, (int) newpos);
743 741
744 if (endp ? EXTENT_E_LESS (e, extent) : EXTENT_LESS (e, extent)) 742 if (endp ? EXTENT_E_LESS (e, extent) : EXTENT_LESS (e, extent))
745 left = newpos+1; 743 left = newpos+1;
746 else 744 else
747 right = newpos; 745 right = newpos;
750 /* Now we're at the beginning of all equal extents. */ 748 /* Now we're at the beginning of all equal extents. */
751 found = 0; 749 found = 0;
752 oldfoundpos = foundpos = left; 750 oldfoundpos = foundpos = left;
753 while (foundpos < GAP_ARRAY_NUM_ELS (ga)) 751 while (foundpos < GAP_ARRAY_NUM_ELS (ga))
754 { 752 {
755 e = EXTENT_GAP_ARRAY_AT (ga, foundpos); 753 EXTENT e = EXTENT_GAP_ARRAY_AT (ga, foundpos);
756 if (e == extent) 754 if (e == extent)
757 { 755 {
758 found = 1; 756 found = 1;
759 break; 757 break;
760 } 758 }
910 908
911 /************************************************************************/ 909 /************************************************************************/
912 /* Auxiliary extent structure */ 910 /* Auxiliary extent structure */
913 /************************************************************************/ 911 /************************************************************************/
914 912
915 static Lisp_Object mark_extent_auxiliary (Lisp_Object obj,
916 void (*markobj) (Lisp_Object));
917 DEFINE_LRECORD_IMPLEMENTATION ("extent-auxiliary", extent_auxiliary,
918 mark_extent_auxiliary, internal_object_printer,
919 0, 0, 0, struct extent_auxiliary);
920
921 static Lisp_Object 913 static Lisp_Object
922 mark_extent_auxiliary (Lisp_Object obj, void (*markobj) (Lisp_Object)) 914 mark_extent_auxiliary (Lisp_Object obj, void (*markobj) (Lisp_Object))
923 { 915 {
924 struct extent_auxiliary *data = XEXTENT_AUXILIARY (obj); 916 struct extent_auxiliary *data = XEXTENT_AUXILIARY (obj);
925 ((markobj) (data->begin_glyph)); 917 ((markobj) (data->begin_glyph));
930 ((markobj) (data->mouse_face)); 922 ((markobj) (data->mouse_face));
931 ((markobj) (data->initial_redisplay_function)); 923 ((markobj) (data->initial_redisplay_function));
932 return data->parent; 924 return data->parent;
933 } 925 }
934 926
927 DEFINE_LRECORD_IMPLEMENTATION ("extent-auxiliary", extent_auxiliary,
928 mark_extent_auxiliary, internal_object_printer,
929 0, 0, 0, struct extent_auxiliary);
930
935 void 931 void
936 allocate_extent_auxiliary (EXTENT ext) 932 allocate_extent_auxiliary (EXTENT ext)
937 { 933 {
938 Lisp_Object extent_aux = Qnil; 934 Lisp_Object extent_aux;
939 struct extent_auxiliary *data = 935 struct extent_auxiliary *data =
940 alloc_lcrecord_type (struct extent_auxiliary, lrecord_extent_auxiliary); 936 alloc_lcrecord_type (struct extent_auxiliary, lrecord_extent_auxiliary);
941 937
942 copy_lcrecord (data, &extent_auxiliary_defaults); 938 copy_lcrecord (data, &extent_auxiliary_defaults);
943 XSETEXTENT_AUXILIARY (extent_aux, data); 939 XSETEXTENT_AUXILIARY (extent_aux, data);
973 969
974 static struct stack_of_extents *allocate_soe (void); 970 static struct stack_of_extents *allocate_soe (void);
975 static void free_soe (struct stack_of_extents *soe); 971 static void free_soe (struct stack_of_extents *soe);
976 static void soe_invalidate (Lisp_Object obj); 972 static void soe_invalidate (Lisp_Object obj);
977 973
978 static Lisp_Object mark_extent_info (Lisp_Object obj,
979 void (*markobj) (Lisp_Object));
980 static void finalize_extent_info (void *header, int for_disksave);
981 DEFINE_LRECORD_IMPLEMENTATION ("extent-info", extent_info,
982 mark_extent_info, internal_object_printer,
983 finalize_extent_info, 0, 0,
984 struct extent_info);
985
986 static Lisp_Object 974 static Lisp_Object
987 mark_extent_info (Lisp_Object obj, void (*markobj) (Lisp_Object)) 975 mark_extent_info (Lisp_Object obj, void (*markobj) (Lisp_Object))
988 { 976 {
989 struct extent_info *data = 977 struct extent_info *data =
990 (struct extent_info *) XEXTENT_INFO (obj); 978 (struct extent_info *) XEXTENT_INFO (obj);
1004 if (list) 992 if (list)
1005 { 993 {
1006 for (i = 0; i < extent_list_num_els (list); i++) 994 for (i = 0; i < extent_list_num_els (list); i++)
1007 { 995 {
1008 struct extent *extent = extent_list_at (list, i, 0); 996 struct extent *extent = extent_list_at (list, i, 0);
1009 Lisp_Object exobj = Qnil; 997 Lisp_Object exobj;
1010 998
1011 XSETEXTENT (exobj, extent); 999 XSETEXTENT (exobj, extent);
1012 ((markobj) (exobj)); 1000 ((markobj) (exobj));
1013 } 1001 }
1014 } 1002 }
1034 free_extent_list (data->extents); 1022 free_extent_list (data->extents);
1035 data->extents = 0; 1023 data->extents = 0;
1036 } 1024 }
1037 } 1025 }
1038 1026
1027 DEFINE_LRECORD_IMPLEMENTATION ("extent-info", extent_info,
1028 mark_extent_info, internal_object_printer,
1029 finalize_extent_info, 0, 0,
1030 struct extent_info);
1031
1039 static Lisp_Object 1032 static Lisp_Object
1040 allocate_extent_info (void) 1033 allocate_extent_info (void)
1041 { 1034 {
1042 Lisp_Object extent_info = Qnil; 1035 Lisp_Object extent_info;
1043 struct extent_info *data = 1036 struct extent_info *data =
1044 alloc_lcrecord_type (struct extent_info, lrecord_extent_info); 1037 alloc_lcrecord_type (struct extent_info, lrecord_extent_info);
1045 1038
1046 XSETEXTENT_INFO (extent_info, data); 1039 XSETEXTENT_INFO (extent_info, data);
1047 data->extents = allocate_extent_list (); 1040 data->extents = allocate_extent_list ();
1080 static Lisp_Object 1073 static Lisp_Object
1081 decode_buffer_or_string (Lisp_Object object) 1074 decode_buffer_or_string (Lisp_Object object)
1082 { 1075 {
1083 if (NILP (object)) 1076 if (NILP (object))
1084 XSETBUFFER (object, current_buffer); 1077 XSETBUFFER (object, current_buffer);
1078 else if (BUFFERP (object))
1079 CHECK_LIVE_BUFFER (object);
1080 else if (STRINGP (object))
1081 ;
1085 else 1082 else
1086 CHECK_LIVE_BUFFER_OR_STRING (object); 1083 dead_wrong_type_argument (Qbuffer_or_string_p, object);
1084
1087 return object; 1085 return object;
1088 } 1086 }
1089 1087
1090 EXTENT 1088 EXTENT
1091 extent_ancestor_1 (EXTENT e) 1089 extent_ancestor_1 (EXTENT e)
1097 e = XEXTENT (XEXTENT_AUXILIARY (XCAR (e->plist))->parent); 1095 e = XEXTENT (XEXTENT_AUXILIARY (XCAR (e->plist))->parent);
1098 } 1096 }
1099 return e; 1097 return e;
1100 } 1098 }
1101 1099
1102 /* Given an extent object (string or buffer or nil), return its extent info. This may be 1100 /* Given an extent object (string or buffer or nil), return its extent info.
1103 0 for a string. */ 1101 This may be 0 for a string. */
1104 1102
1105 static struct extent_info * 1103 static struct extent_info *
1106 buffer_or_string_extent_info (Lisp_Object object) 1104 buffer_or_string_extent_info (Lisp_Object object)
1107 { 1105 {
1108 if (STRINGP (object)) 1106 if (STRINGP (object))
1281 Lisp_Object extent; 1279 Lisp_Object extent;
1282 char buf[200]; 1280 char buf[200];
1283 1281
1284 XSETEXTENT (extent, e); 1282 XSETEXTENT (extent, e);
1285 print_extent_1 (buf, extent); 1283 print_extent_1 (buf, extent);
1286 printf ("%s", buf); 1284 fputs (buf, stdout);
1287 } 1285 }
1288 1286
1289 static void 1287 static void
1290 soe_dump (Lisp_Object obj) 1288 soe_dump (Lisp_Object obj)
1291 { 1289 {
1308 { 1306 {
1309 printf (endp ? "SOE end:" : "SOE start:"); 1307 printf (endp ? "SOE end:" : "SOE start:");
1310 for (i = 0; i < extent_list_num_els (sel); i++) 1308 for (i = 0; i < extent_list_num_els (sel); i++)
1311 { 1309 {
1312 EXTENT e = extent_list_at (sel, i, endp); 1310 EXTENT e = extent_list_at (sel, i, endp);
1313 printf ("\t"); 1311 putchar ('\t');
1314 print_extent_2 (e); 1312 print_extent_2 (e);
1315 } 1313 }
1316 printf ("\n"); 1314 putchar ('\n');
1317 } 1315 }
1318 printf ("\n"); 1316 putchar ('\n');
1319 } 1317 }
1320 1318
1321 #endif 1319 #endif
1322 1320
1323 /* Insert EXTENT into OBJ's stack of extents, if necessary. */ 1321 /* Insert EXTENT into OBJ's stack of extents, if necessary. */
1328 Stack_Of_Extents *soe = buffer_or_string_stack_of_extents (obj); 1326 Stack_Of_Extents *soe = buffer_or_string_stack_of_extents (obj);
1329 1327
1330 #ifdef SOE_DEBUG 1328 #ifdef SOE_DEBUG
1331 printf ("Inserting into SOE: "); 1329 printf ("Inserting into SOE: ");
1332 print_extent_2 (extent); 1330 print_extent_2 (extent);
1333 printf ("\n"); 1331 putchar ('\n');
1334 #endif 1332 #endif
1335 if (!soe || soe->pos < extent_start (extent) || 1333 if (!soe || soe->pos < extent_start (extent) ||
1336 soe->pos > extent_end (extent)) 1334 soe->pos > extent_end (extent))
1337 { 1335 {
1338 #ifdef SOE_DEBUG 1336 #ifdef SOE_DEBUG
1340 #endif 1338 #endif
1341 return; 1339 return;
1342 } 1340 }
1343 extent_list_insert (soe->extents, extent); 1341 extent_list_insert (soe->extents, extent);
1344 #ifdef SOE_DEBUG 1342 #ifdef SOE_DEBUG
1345 printf ("SOE afterwards is:\n"); 1343 puts ("SOE afterwards is:");
1346 soe_dump (obj); 1344 soe_dump (obj);
1347 #endif 1345 #endif
1348 } 1346 }
1349 1347
1350 /* Delete EXTENT from OBJ's stack of extents, if necessary. */ 1348 /* Delete EXTENT from OBJ's stack of extents, if necessary. */
1355 Stack_Of_Extents *soe = buffer_or_string_stack_of_extents (obj); 1353 Stack_Of_Extents *soe = buffer_or_string_stack_of_extents (obj);
1356 1354
1357 #ifdef SOE_DEBUG 1355 #ifdef SOE_DEBUG
1358 printf ("Deleting from SOE: "); 1356 printf ("Deleting from SOE: ");
1359 print_extent_2 (extent); 1357 print_extent_2 (extent);
1360 printf ("\n"); 1358 putchar ('\n');
1361 #endif 1359 #endif
1362 if (!soe || soe->pos < extent_start (extent) || 1360 if (!soe || soe->pos < extent_start (extent) ||
1363 soe->pos > extent_end (extent)) 1361 soe->pos > extent_end (extent))
1364 { 1362 {
1365 #ifdef SOE_DEBUG 1363 #ifdef SOE_DEBUG
1366 printf ("(not needed)\n\n"); 1364 puts ("(not needed)\n");
1367 #endif 1365 #endif
1368 return; 1366 return;
1369 } 1367 }
1370 extent_list_delete (soe->extents, extent); 1368 extent_list_delete (soe->extents, extent);
1371 #ifdef SOE_DEBUG 1369 #ifdef SOE_DEBUG
1372 printf ("SOE afterwards is:\n"); 1370 puts ("SOE afterwards is:");
1373 soe_dump (obj); 1371 soe_dump (obj);
1374 #endif 1372 #endif
1375 } 1373 }
1376 1374
1377 /* Move OBJ's stack of extents to lie over the specified position. */ 1375 /* Move OBJ's stack of extents to lie over the specified position. */
1407 endp = 1; 1405 endp = 1;
1408 } 1406 }
1409 else 1407 else
1410 { 1408 {
1411 #ifdef SOE_DEBUG 1409 #ifdef SOE_DEBUG
1412 printf ("(not needed)\n\n"); 1410 puts ("(not needed)\n");
1413 #endif 1411 #endif
1414 return; 1412 return;
1415 } 1413 }
1416 1414
1417 /* For DIRECTION = 1: Any extent that overlaps POS is either in the 1415 /* For DIRECTION = 1: Any extent that overlaps POS is either in the
1493 } 1491 }
1494 } 1492 }
1495 1493
1496 soe->pos = pos; 1494 soe->pos = pos;
1497 #ifdef SOE_DEBUG 1495 #ifdef SOE_DEBUG
1498 printf ("SOE afterwards is:\n"); 1496 puts ("SOE afterwards is:");
1499 soe_dump (obj); 1497 soe_dump (obj);
1500 #endif 1498 #endif
1501 } 1499 }
1502 1500
1503 static void 1501 static void
1640 if (!NILP (extent_face (anc)) || 1638 if (!NILP (extent_face (anc)) ||
1641 !NILP (extent_begin_glyph (anc)) || 1639 !NILP (extent_begin_glyph (anc)) ||
1642 !NILP (extent_end_glyph (anc)) || 1640 !NILP (extent_end_glyph (anc)) ||
1643 !NILP (extent_mouse_face (anc)) || 1641 !NILP (extent_mouse_face (anc)) ||
1644 !NILP (extent_invisible (anc)) || 1642 !NILP (extent_invisible (anc)) ||
1645 !NILP (extent_initial_redisplay_function (anc)) || 1643 !NILP (extent_initial_redisplay_function (anc)) ||
1646 invisibility_change) 1644 invisibility_change)
1647 extent_changed_for_redisplay (extent, descendants_too, 1645 extent_changed_for_redisplay (extent, descendants_too,
1648 invisibility_change); 1646 invisibility_change);
1649 } 1647 }
1650 1648
1714 static EXTENT 1712 static EXTENT
1715 extent_next (EXTENT e) 1713 extent_next (EXTENT e)
1716 { 1714 {
1717 Extent_List *el = extent_extent_list (e); 1715 Extent_List *el = extent_extent_list (e);
1718 int foundp; 1716 int foundp;
1719 int pos; 1717 int pos = extent_list_locate (el, e, 0, &foundp);
1720
1721 pos = extent_list_locate (el, e, 0, &foundp);
1722 assert (foundp); 1718 assert (foundp);
1723 return real_extent_at_forward (el, pos+1, 0); 1719 return real_extent_at_forward (el, pos+1, 0);
1724 } 1720 }
1725 1721
1726 #ifdef DEBUG_XEMACS 1722 #ifdef DEBUG_XEMACS
1727 static EXTENT 1723 static EXTENT
1728 extent_e_next (EXTENT e) 1724 extent_e_next (EXTENT e)
1729 { 1725 {
1730 Extent_List *el = extent_extent_list (e); 1726 Extent_List *el = extent_extent_list (e);
1731 int foundp; 1727 int foundp;
1732 int pos; 1728 int pos = extent_list_locate (el, e, 1, &foundp);
1733
1734 pos = extent_list_locate (el, e, 1, &foundp);
1735 assert (foundp); 1729 assert (foundp);
1736 return real_extent_at_forward (el, pos+1, 1); 1730 return real_extent_at_forward (el, pos+1, 1);
1737 } 1731 }
1738 #endif 1732 #endif
1739 1733
1762 static EXTENT 1756 static EXTENT
1763 extent_previous (EXTENT e) 1757 extent_previous (EXTENT e)
1764 { 1758 {
1765 Extent_List *el = extent_extent_list (e); 1759 Extent_List *el = extent_extent_list (e);
1766 int foundp; 1760 int foundp;
1767 int pos; 1761 int pos = extent_list_locate (el, e, 0, &foundp);
1768
1769 pos = extent_list_locate (el, e, 0, &foundp);
1770 assert (foundp); 1762 assert (foundp);
1771 return real_extent_at_backward (el, pos-1, 0); 1763 return real_extent_at_backward (el, pos-1, 0);
1772 } 1764 }
1773 1765
1774 #ifdef DEBUG_XEMACS 1766 #ifdef DEBUG_XEMACS
1775 static EXTENT 1767 static EXTENT
1776 extent_e_previous (EXTENT e) 1768 extent_e_previous (EXTENT e)
1777 { 1769 {
1778 Extent_List *el = extent_extent_list (e); 1770 Extent_List *el = extent_extent_list (e);
1779 int foundp; 1771 int foundp;
1780 int pos; 1772 int pos = extent_list_locate (el, e, 1, &foundp);
1781
1782 pos = extent_list_locate (el, e, 1, &foundp);
1783 assert (foundp); 1773 assert (foundp);
1784 return real_extent_at_backward (el, pos-1, 1); 1774 return real_extent_at_backward (el, pos-1, 1);
1785 } 1775 }
1786 #endif 1776 #endif
1787 1777
1940 Furthermore, the results might be a little less sensible than 1930 Furthermore, the results might be a little less sensible than
1941 the logic below. */ 1931 the logic below. */
1942 1932
1943 1933
1944 static void 1934 static void
1945 map_extents_bytind (Bytind from, Bytind to, 1935 map_extents_bytind (Bytind from, Bytind to, map_extents_fun fn, void *arg,
1946 int (*fn) (EXTENT extent, void *arg), void *arg,
1947 Lisp_Object obj, EXTENT after, unsigned int flags) 1936 Lisp_Object obj, EXTENT after, unsigned int flags)
1948 { 1937 {
1949 Memind st, en; /* range we're mapping over */ 1938 Memind st, en; /* range we're mapping over */
1950 EXTENT range = 0; /* extent for this, if ME_MIGHT_MODIFY_TEXT */ 1939 EXTENT range = 0; /* extent for this, if ME_MIGHT_MODIFY_TEXT */
1951 Extent_List *el = 0; /* extent list we're iterating over */ 1940 Extent_List *el = 0; /* extent list we're iterating over */
2274 extent_list_delete_marker (el, posm); 2263 extent_list_delete_marker (el, posm);
2275 } 2264 }
2276 } 2265 }
2277 2266
2278 void 2267 void
2279 map_extents (Bufpos from, Bufpos to, int (*fn) (EXTENT extent, void *arg), 2268 map_extents (Bufpos from, Bufpos to, map_extents_fun fn,
2280 void *arg, Lisp_Object obj, EXTENT after, unsigned int flags) 2269 void *arg, Lisp_Object obj, EXTENT after, unsigned int flags)
2281 { 2270 {
2282 map_extents_bytind (buffer_or_string_bufpos_to_bytind (obj, from), 2271 map_extents_bytind (buffer_or_string_bufpos_to_bytind (obj, from),
2283 buffer_or_string_bufpos_to_bytind (obj, to), fn, arg, 2272 buffer_or_string_bufpos_to_bytind (obj, to), fn, arg,
2284 obj, after, flags); 2273 obj, after, flags);
2794 { 2783 {
2795 Lisp_Object glyph = extent_begin_glyph (e); 2784 Lisp_Object glyph = extent_begin_glyph (e);
2796 struct glyph_block gb; 2785 struct glyph_block gb;
2797 2786
2798 gb.glyph = glyph; 2787 gb.glyph = glyph;
2799 gb.extent = Qnil;
2800 XSETEXTENT (gb.extent, e); 2788 XSETEXTENT (gb.extent, e);
2801 Dynarr_add (ef->begin_glyphs, gb); 2789 Dynarr_add (ef->begin_glyphs, gb);
2802 } 2790 }
2803 } 2791 }
2804 2792
2810 { 2798 {
2811 Lisp_Object glyph = extent_end_glyph (e); 2799 Lisp_Object glyph = extent_end_glyph (e);
2812 struct glyph_block gb; 2800 struct glyph_block gb;
2813 2801
2814 gb.glyph = glyph; 2802 gb.glyph = glyph;
2815 gb.extent = Qnil;
2816 XSETEXTENT (gb.extent, e); 2803 XSETEXTENT (gb.extent, e);
2817 Dynarr_add (ef->end_glyphs, gb); 2804 Dynarr_add (ef->end_glyphs, gb);
2818 } 2805 }
2819 } 2806 }
2820 2807
2870 if (!NILP (extent_face (e))) 2857 if (!NILP (extent_face (e)))
2871 Dynarr_add (ef->extents, e); 2858 Dynarr_add (ef->extents, e);
2872 if (e == lhe) 2859 if (e == lhe)
2873 { 2860 {
2874 Lisp_Object f; 2861 Lisp_Object f;
2875 /* memset isn't really necessary; we only deref `priority' 2862 /* zeroing isn't really necessary; we only deref `priority'
2876 and `face' */ 2863 and `face' */
2877 memset (&dummy_lhe_extent, 0, sizeof (dummy_lhe_extent)); 2864 xzero (dummy_lhe_extent);
2878 set_extent_priority (&dummy_lhe_extent, 2865 set_extent_priority (&dummy_lhe_extent,
2879 mouse_highlight_priority); 2866 mouse_highlight_priority);
2880 /* Need to break up thefollowing expression, due to an */ 2867 /* Need to break up thefollowing expression, due to an */
2881 /* error in the Digital UNIX 3.2g C compiler (Digital */ 2868 /* error in the Digital UNIX 3.2g C compiler (Digital */
2882 /* UNIX Compiler Driver 3.11). */ 2869 /* UNIX Compiler Driver 3.11). */
2889 !extent_in_red_event_p(e)) 2876 !extent_in_red_event_p(e))
2890 { 2877 {
2891 Lisp_Object function = extent_initial_redisplay_function (e); 2878 Lisp_Object function = extent_initial_redisplay_function (e);
2892 Lisp_Object obj; 2879 Lisp_Object obj;
2893 2880
2894 /* printf("initial redisplay function called!\n "); */ 2881 /* printf ("initial redisplay function called!\n "); */
2895 2882
2896 /* print_extent_2(e); 2883 /* print_extent_2 (e);
2897 printf("\n"); */ 2884 printf ("\n"); */
2898 2885
2899 /* FIXME: One should probably inhibit the displaying of 2886 /* FIXME: One should probably inhibit the displaying of
2900 this extent to reduce flicker */ 2887 this extent to reduce flicker */
2901 extent_in_red_event_p(e) = 1; 2888 extent_in_red_event_p(e) = 1;
2902 2889
2903 /* call the function */ 2890 /* call the function */
2904 XSETEXTENT(obj,e); 2891 XSETEXTENT(obj,e);
2905 if(!NILP(function)) 2892 if(!NILP(function))
2906 Fenqueue_eval_event(function,obj); 2893 Fenqueue_eval_event(function,obj);
2907 } 2894 }
2969 /* Retrieve the ancestor and use it, for faster retrieval of properties */ 2956 /* Retrieve the ancestor and use it, for faster retrieval of properties */
2970 2957
2971 if (!NILP (extent_begin_glyph (anc))) *bp++ = '*'; 2958 if (!NILP (extent_begin_glyph (anc))) *bp++ = '*';
2972 *bp++ = (extent_start_open_p (anc) ? '(': '['); 2959 *bp++ = (extent_start_open_p (anc) ? '(': '[');
2973 if (extent_detached_p (ext)) 2960 if (extent_detached_p (ext))
2974 sprintf (bp, "detached"); 2961 strcpy (bp, "detached");
2975 else 2962 else
2976 { 2963 {
2977 Bufpos from = XINT (Fextent_start_position (obj)); 2964 Bufpos from = XINT (Fextent_start_position (obj));
2978 Bufpos to = XINT (Fextent_end_position (obj)); 2965 Bufpos to = XINT (Fextent_end_position (obj));
2979 sprintf (bp, "%d, %d", from, to); 2966 sprintf (bp, "%d, %d", from, to);
3270 else 3257 else
3271 return make_int (extent_endpoint_bufpos (extent, endp)); 3258 return make_int (extent_endpoint_bufpos (extent, endp));
3272 } 3259 }
3273 3260
3274 DEFUN ("extentp", Fextentp, 1, 1, 0, /* 3261 DEFUN ("extentp", Fextentp, 1, 1, 0, /*
3275 T if OBJECT is an extent. 3262 Return t if OBJECT is an extent.
3276 */ 3263 */
3277 (object)) 3264 (object))
3278 { 3265 {
3279 if (EXTENTP (object)) 3266 return EXTENTP (object) ? Qt : Qnil;
3280 return Qt;
3281 return Qnil;
3282 } 3267 }
3283 3268
3284 DEFUN ("extent-live-p", Fextent_live_p, 1, 1, 0, /* 3269 DEFUN ("extent-live-p", Fextent_live_p, 1, 1, 0, /*
3285 T if OBJECT is an extent and the extent has not been destroyed. 3270 Return t if OBJECT is an extent that has not been destroyed.
3286 */ 3271 */
3287 (object)) 3272 (object))
3288 { 3273 {
3289 if (EXTENTP (object) && EXTENT_LIVE_P (XEXTENT (object))) 3274 return EXTENTP (object) && EXTENT_LIVE_P (XEXTENT (object)) ? Qt : Qnil;
3290 return Qt;
3291 return Qnil;
3292 } 3275 }
3293 3276
3294 DEFUN ("extent-detached-p", Fextent_detached_p, 1, 1, 0, /* 3277 DEFUN ("extent-detached-p", Fextent_detached_p, 1, 1, 0, /*
3295 T if EXTENT is detached. 3278 Return t if EXTENT is detached.
3296 */ 3279 */
3297 (extent)) 3280 (extent))
3298 { 3281 {
3299 if (extent_detached_p (decode_extent (extent, 0))) 3282 return extent_detached_p (decode_extent (extent, 0)) ? Qt : Qnil;
3300 return Qt;
3301 return Qnil;
3302 } 3283 }
3303 3284
3304 DEFUN ("extent-object", Fextent_object, 1, 1, 0, /* 3285 DEFUN ("extent-object", Fextent_object, 1, 1, 0, /*
3305 Return object (buffer or string) EXTENT refers to. 3286 Return object (buffer or string) that EXTENT refers to.
3306 */ 3287 */
3307 (extent)) 3288 (extent))
3308 { 3289 {
3309 return extent_object (decode_extent (extent, 0)); 3290 return extent_object (decode_extent (extent, 0));
3310 } 3291 }
3648 } 3629 }
3649 3630
3650 static void 3631 static void
3651 set_extent_openness (EXTENT extent, int start_open, int end_open) 3632 set_extent_openness (EXTENT extent, int start_open, int end_open)
3652 { 3633 {
3653 if (start_open == -1) 3634 if (start_open != -1)
3654 start_open = extent_start_open_p (extent); 3635 extent_start_open_p (extent) = start_open;
3655 if (end_open == -1) 3636 if (end_open != -1)
3656 end_open = extent_end_open_p (extent); 3637 extent_end_open_p (extent) = end_open;
3657 extent_start_open_p (extent) = start_open;
3658 extent_end_open_p (extent) = end_open;
3659 /* changing the open/closedness of an extent does not affect 3638 /* changing the open/closedness of an extent does not affect
3660 redisplay. */ 3639 redisplay. */
3661 } 3640 }
3662 3641
3663 static EXTENT 3642 static EXTENT
3710 3689
3711 static void 3690 static void
3712 destroy_extent (EXTENT extent) 3691 destroy_extent (EXTENT extent)
3713 { 3692 {
3714 Lisp_Object rest, nextrest, children; 3693 Lisp_Object rest, nextrest, children;
3715 Lisp_Object extent_obj = Qnil; 3694 Lisp_Object extent_obj;
3716 3695
3717 if (!extent_detached_p (extent)) 3696 if (!extent_detached_p (extent))
3718 extent_detach (extent); 3697 extent_detach (extent);
3719 /* disassociate the extent from its children and parent */ 3698 /* disassociate the extent from its children and parent */
3720 children = extent_children (extent); 3699 children = extent_children (extent);
3739 FROM and TO are nil, and in this case BUFFER-OR-STRING defaults to nil, 3718 FROM and TO are nil, and in this case BUFFER-OR-STRING defaults to nil,
3740 meaning the extent is in no buffer and no string. 3719 meaning the extent is in no buffer and no string.
3741 */ 3720 */
3742 (from, to, buffer_or_string)) 3721 (from, to, buffer_or_string))
3743 { 3722 {
3744 Lisp_Object extent_obj = Qnil; 3723 Lisp_Object extent_obj;
3745 Lisp_Object obj; 3724 Lisp_Object obj;
3746 3725
3747 obj = decode_buffer_or_string (buffer_or_string); 3726 obj = decode_buffer_or_string (buffer_or_string);
3748 if (NILP (from) && NILP (to)) 3727 if (NILP (from) && NILP (to))
3749 { 3728 {
3900 in_region_specified = 1; 3879 in_region_specified = 1;
3901 } 3880 }
3902 3881
3903 /* I do so love that conditional operator ... */ 3882 /* I do so love that conditional operator ... */
3904 retval |= 3883 retval |=
3905 EQ (sym, Qend_closed) ? ME_END_CLOSED : 3884 EQ (sym, Qend_closed) ? ME_END_CLOSED :
3906 EQ (sym, Qstart_open) ? ME_START_OPEN : 3885 EQ (sym, Qstart_open) ? ME_START_OPEN :
3907 EQ (sym, Qall_extents_closed) ? ME_ALL_EXTENTS_CLOSED : 3886 EQ (sym, Qall_extents_closed) ? ME_ALL_EXTENTS_CLOSED :
3908 EQ (sym, Qall_extents_open) ? ME_ALL_EXTENTS_OPEN : 3887 EQ (sym, Qall_extents_open) ? ME_ALL_EXTENTS_OPEN :
3909 EQ (sym, Qall_extents_closed_open) ? ME_ALL_EXTENTS_CLOSED_OPEN : 3888 EQ (sym, Qall_extents_closed_open) ? ME_ALL_EXTENTS_CLOSED_OPEN :
3910 EQ (sym, Qall_extents_open_closed) ? ME_ALL_EXTENTS_OPEN_CLOSED : 3889 EQ (sym, Qall_extents_open_closed) ? ME_ALL_EXTENTS_OPEN_CLOSED :
3911 EQ (sym, Qstart_in_region) ? ME_START_IN_REGION : 3890 EQ (sym, Qstart_in_region) ? ME_START_IN_REGION :
3912 EQ (sym, Qend_in_region) ? ME_END_IN_REGION : 3891 EQ (sym, Qend_in_region) ? ME_END_IN_REGION :
3913 EQ (sym, Qstart_and_end_in_region) ? ME_START_AND_END_IN_REGION : 3892 EQ (sym, Qstart_and_end_in_region) ? ME_START_AND_END_IN_REGION :
3914 EQ (sym, Qstart_or_end_in_region) ? ME_START_OR_END_IN_REGION : 3893 EQ (sym, Qstart_or_end_in_region) ? ME_START_OR_END_IN_REGION :
3915 EQ (sym, Qnegate_in_region) ? ME_NEGATE_IN_REGION : 3894 EQ (sym, Qnegate_in_region) ? ME_NEGATE_IN_REGION :
3916 (signal_simple_error ("Invalid `map-extents' flag", sym), 0); 3895 (signal_simple_error ("Invalid `map-extents' flag", sym), 0);
3917 3896
3918 flags = XCDR (flags); 3897 flags = XCDR (flags);
3919 } 3898 }
3920 return retval; 3899 return retval;
3925 This is equivalent to whether `map-extents' would visit EXTENT when called 3904 This is equivalent to whether `map-extents' would visit EXTENT when called
3926 with these args. 3905 with these args.
3927 */ 3906 */
3928 (extent, from, to, flags)) 3907 (extent, from, to, flags))
3929 { 3908 {
3930 EXTENT ext;
3931 Lisp_Object obj;
3932 Bytind start, end; 3909 Bytind start, end;
3933 3910 EXTENT ext = decode_extent (extent, DE_MUST_BE_ATTACHED);
3934 ext = decode_extent (extent, DE_MUST_BE_ATTACHED); 3911 Lisp_Object obj = extent_object (ext);
3935 obj = extent_object (ext); 3912
3936 get_buffer_or_string_range_byte (obj, from, to, &start, &end, GB_ALLOW_NIL | 3913 get_buffer_or_string_range_byte (obj, from, to, &start, &end, GB_ALLOW_NIL |
3937 GB_ALLOW_PAST_ACCESSIBLE); 3914 GB_ALLOW_PAST_ACCESSIBLE);
3938 3915
3939 if (extent_in_region_p (ext, start, end, decode_map_extents_flags (flags))) 3916 return extent_in_region_p (ext, start, end, decode_map_extents_flags (flags)) ?
3940 return Qt; 3917 Qt : Qnil;
3941 return Qnil;
3942 } 3918 }
3943 3919
3944 struct slow_map_extents_arg 3920 struct slow_map_extents_arg
3945 { 3921 {
3946 Lisp_Object map_arg; 3922 Lisp_Object map_arg;
3971 return 0; 3947 return 0;
3972 } 3948 }
3973 3949
3974 closure->result = call2 (closure->map_routine, extent_obj, 3950 closure->result = call2 (closure->map_routine, extent_obj,
3975 closure->map_arg); 3951 closure->map_arg);
3976 if (NILP (closure->result)) 3952 return !NILP (closure->result);
3977 return 0;
3978 else
3979 return 1;
3980 } 3953 }
3981 3954
3982 DEFUN ("map-extents", Fmap_extents, 1, 8, 0, /* 3955 DEFUN ("map-extents", Fmap_extents, 1, 8, 0, /*
3983 Map FUNCTION over the extents which overlap a region in OBJECT. 3956 Map FUNCTION over the extents which overlap a region in OBJECT.
3984 OBJECT is normally a buffer or string but could be an extent (see below). 3957 OBJECT is normally a buffer or string but could be an extent (see below).
4174 */ 4147 */
4175 closure->start_min = -1; /* no need for this any more */ 4148 closure->start_min = -1; /* no need for this any more */
4176 closure->prev_start = extent_endpoint_bytind (extent, 0); 4149 closure->prev_start = extent_endpoint_bytind (extent, 0);
4177 closure->prev_end = extent_endpoint_bytind (extent, 1); 4150 closure->prev_end = extent_endpoint_bytind (extent, 1);
4178 4151
4179 if (NILP (closure->result)) 4152 return !NILP (closure->result);
4180 return 0;
4181 else
4182 return 1;
4183 } 4153 }
4184 4154
4185 DEFUN ("map-extent-children", Fmap_extent_children, 1, 8, 0, /* 4155 DEFUN ("map-extent-children", Fmap_extent_children, 1, 8, 0, /*
4186 Map FUNCTION over the extents in the region from FROM to TO. 4156 Map FUNCTION over the extents in the region from FROM to TO.
4187 FUNCTION is called with arguments (extent, MAPARG). See `map-extents' 4157 FUNCTION is called with arguments (extent, MAPARG). See `map-extents'
4275 }; 4245 };
4276 4246
4277 static enum extent_at_flag 4247 static enum extent_at_flag
4278 decode_extent_at_flag (Lisp_Object at_flag) 4248 decode_extent_at_flag (Lisp_Object at_flag)
4279 { 4249 {
4280 enum extent_at_flag fl;
4281
4282 if (NILP (at_flag)) 4250 if (NILP (at_flag))
4283 fl = EXTENT_AT_AFTER; 4251 return EXTENT_AT_AFTER;
4284 else 4252
4285 { 4253 CHECK_SYMBOL (at_flag);
4286 CHECK_SYMBOL (at_flag); 4254 if (EQ (at_flag, Qafter)) return EXTENT_AT_AFTER;
4287 if (EQ (at_flag, Qafter)) 4255 if (EQ (at_flag, Qbefore)) return EXTENT_AT_BEFORE;
4288 fl = EXTENT_AT_AFTER; 4256 if (EQ (at_flag, Qat)) return EXTENT_AT_AT;
4289 else if (EQ (at_flag, Qbefore)) 4257
4290 fl = EXTENT_AT_BEFORE; 4258 signal_simple_error ("Invalid AT-FLAG in `extent-at'", at_flag);
4291 else if (EQ (at_flag, Qat)) 4259 return EXTENT_AT_AFTER; /* unreached */
4292 fl = EXTENT_AT_AT;
4293 else
4294 signal_simple_error ("Invalid AT-FLAG in `extent-at'", at_flag);
4295 }
4296
4297 return fl;
4298 } 4260 }
4299 4261
4300 static int 4262 static int
4301 extent_at_mapper (EXTENT e, void *arg) 4263 extent_at_mapper (EXTENT e, void *arg)
4302 { 4264 {
4345 static Lisp_Object 4307 static Lisp_Object
4346 extent_at_bytind (Bytind position, Lisp_Object object, Lisp_Object property, 4308 extent_at_bytind (Bytind position, Lisp_Object object, Lisp_Object property,
4347 EXTENT before, enum extent_at_flag at_flag) 4309 EXTENT before, enum extent_at_flag at_flag)
4348 { 4310 {
4349 struct extent_at_arg closure; 4311 struct extent_at_arg closure;
4350 Lisp_Object extent_obj = Qnil; 4312 Lisp_Object extent_obj;
4351 4313
4352 /* it might be argued that invalid positions should cause 4314 /* it might be argued that invalid positions should cause
4353 errors, but the principle of least surprise dictates that 4315 errors, but the principle of least surprise dictates that
4354 nil should be returned (extent-at is often used in 4316 nil should be returned (extent-at is often used in
4355 response to a mouse event, and in many cases previous events 4317 response to a mouse event, and in many cases previous events
4788 (memoize_extent_face_internal (value))); 4750 (memoize_extent_face_internal (value)));
4789 return value; 4751 return value;
4790 } 4752 }
4791 4753
4792 /* Do we need a lisp-level function ? */ 4754 /* Do we need a lisp-level function ? */
4793 DEFUN ("set-extent-initial-redisplay-function", Fset_extent_initial_redisplay_function, 4755 DEFUN ("set-extent-initial-redisplay-function",
4794 2,2,0,/* 4756 Fset_extent_initial_redisplay_function, 2,2,0,/*
4795 Note: This feature is experimental! 4757 Note: This feature is experimental!
4796 4758
4797 Set initial-redisplay-function of EXTENT to the function 4759 Set initial-redisplay-function of EXTENT to the function
4798 FUNCTION. 4760 FUNCTION.
4799 4761
4800 The first time the EXTENT is (re)displayed, an eval event will be 4762 The first time the EXTENT is (re)displayed, an eval event will be
4801 dispatched calling FUNCTION with EXTENT as its only argument. 4763 dispatched calling FUNCTION with EXTENT as its only argument.
4802 */ 4764 */
4803 (extent, function)) 4765 (extent, function))
4804 { 4766 {
4805 EXTENT e = decode_extent(extent, DE_MUST_BE_ATTACHED); 4767 EXTENT e = decode_extent(extent, DE_MUST_BE_ATTACHED);
4806 4768
4807 e = extent_ancestor (e); /* Is this needed? Macro also does chasing!*/ 4769 e = extent_ancestor (e); /* Is this needed? Macro also does chasing!*/
4808 set_extent_initial_redisplay_function(e,function); 4770 set_extent_initial_redisplay_function(e,function);
4809 extent_in_red_event_p(e) = 0; /* If the function changed we can spawn 4771 extent_in_red_event_p(e) = 0; /* If the function changed we can spawn
4810 new events */ 4772 new events */
4811 extent_changed_for_redisplay(e,1,0); /* Do we need to mark children too ?*/ 4773 extent_changed_for_redisplay(e,1,0); /* Do we need to mark children too ?*/
4812 4774
4813 return function; 4775 return function;
4814 } 4776 }
4815
4816
4817
4818 4777
4819 DEFUN ("extent-face", Fextent_face, 1, 1, 0, /* 4778 DEFUN ("extent-face", Fextent_face, 1, 1, 0, /*
4820 Return the name of the face in which EXTENT is displayed, or nil 4779 Return the name of the face in which EXTENT is displayed, or nil
4821 if the extent's face is unspecified. This might also return a list 4780 if the extent's face is unspecified. This might also return a list
4822 of face names. 4781 of face names.
4823 */ 4782 */
4824 (extent)) 4783 (extent))
4825 { 4784 {
4826 Lisp_Object face; 4785 Lisp_Object face;
4827 4786
4893 return orig_face; 4852 return orig_face;
4894 } 4853 }
4895 4854
4896 void 4855 void
4897 set_extent_glyph (EXTENT extent, Lisp_Object glyph, int endp, 4856 set_extent_glyph (EXTENT extent, Lisp_Object glyph, int endp,
4898 unsigned int layout) 4857 glyph_layout layout)
4899 { 4858 {
4900 extent = extent_ancestor (extent); 4859 extent = extent_ancestor (extent);
4901 4860
4902 if (!endp) 4861 if (!endp)
4903 { 4862 {
4912 4871
4913 extent_changed_for_redisplay (extent, 1, 0); 4872 extent_changed_for_redisplay (extent, 1, 0);
4914 } 4873 }
4915 4874
4916 static Lisp_Object 4875 static Lisp_Object
4917 glyph_layout_to_symbol (unsigned int layout) 4876 glyph_layout_to_symbol (glyph_layout layout)
4918 { 4877 {
4919 switch (layout) 4878 switch (layout)
4920 { 4879 {
4921 case GL_TEXT: return Qtext; 4880 case GL_TEXT: return Qtext;
4922 case GL_OUTSIDE_MARGIN: return Qoutside_margin; 4881 case GL_OUTSIDE_MARGIN: return Qoutside_margin;
4923 case GL_INSIDE_MARGIN: return Qinside_margin; 4882 case GL_INSIDE_MARGIN: return Qinside_margin;
4924 case GL_WHITESPACE: return Qwhitespace; 4883 case GL_WHITESPACE: return Qwhitespace;
4925 default: abort (); 4884 default:
4926 } 4885 abort ();
4927 return Qnil; /* shut up compiler */ 4886 return Qnil; /* unreached */
4928 } 4887 }
4929 4888 }
4930 static unsigned int 4889
4890 static glyph_layout
4931 symbol_to_glyph_layout (Lisp_Object layout_obj) 4891 symbol_to_glyph_layout (Lisp_Object layout_obj)
4932 { 4892 {
4933 unsigned int layout = 0;
4934
4935 if (NILP (layout_obj)) 4893 if (NILP (layout_obj))
4936 layout = GL_TEXT; 4894 return GL_TEXT;
4937 else 4895
4938 { 4896 CHECK_SYMBOL (layout_obj);
4939 CHECK_SYMBOL (layout_obj); 4897 if (EQ (layout_obj, Qoutside_margin)) return GL_OUTSIDE_MARGIN;
4940 if (EQ (Qoutside_margin, layout_obj)) 4898 if (EQ (layout_obj, Qinside_margin)) return GL_INSIDE_MARGIN;
4941 layout = GL_OUTSIDE_MARGIN; 4899 if (EQ (layout_obj, Qwhitespace)) return GL_WHITESPACE;
4942 else if (EQ (Qinside_margin, layout_obj)) 4900 if (EQ (layout_obj, Qtext)) return GL_TEXT;
4943 layout = GL_INSIDE_MARGIN; 4901
4944 else if (EQ (Qwhitespace, layout_obj)) 4902 signal_simple_error ("unknown glyph layout type", layout_obj);
4945 layout = GL_WHITESPACE; 4903 return GL_TEXT; /* unreached */
4946 else if (EQ (Qtext, layout_obj))
4947 layout = GL_TEXT;
4948 else
4949 signal_simple_error ("unknown glyph layout type", layout_obj);
4950 }
4951 return layout;
4952 } 4904 }
4953 4905
4954 static Lisp_Object 4906 static Lisp_Object
4955 set_extent_glyph_1 (Lisp_Object extent_obj, Lisp_Object glyph, int endp, 4907 set_extent_glyph_1 (Lisp_Object extent_obj, Lisp_Object glyph, int endp,
4956 Lisp_Object layout_obj) 4908 Lisp_Object layout_obj)
4957 { 4909 {
4958 EXTENT extent = decode_extent (extent_obj, DE_MUST_HAVE_BUFFER); 4910 EXTENT extent = decode_extent (extent_obj, DE_MUST_HAVE_BUFFER);
4959 unsigned int layout = symbol_to_glyph_layout (layout_obj); 4911 glyph_layout layout = symbol_to_glyph_layout (layout_obj);
4960 4912
4961 /* Make sure we've actually been given a glyph or it's nil (meaning 4913 /* Make sure we've actually been given a glyph or it's nil (meaning
4962 we're deleting a glyph from an extent). */ 4914 we're deleting a glyph from an extent). */
4963 if (!NILP (glyph)) 4915 if (!NILP (glyph))
4964 CHECK_GLYPH (glyph); 4916 CHECK_GLYPH (glyph);
5048 EXTENT e = decode_extent (extent, 0); 5000 EXTENT e = decode_extent (extent, 0);
5049 return glyph_layout_to_symbol (extent_end_glyph_layout (e)); 5001 return glyph_layout_to_symbol (extent_end_glyph_layout (e));
5050 } 5002 }
5051 5003
5052 DEFUN ("set-extent-priority", Fset_extent_priority, 2, 2, 0, /* 5004 DEFUN ("set-extent-priority", Fset_extent_priority, 2, 2, 0, /*
5053 Changes the display priority of EXTENT. 5005 Set the display priority of EXTENT to PRIORITY (an integer).
5054 When the extent attributes are being merged for display, the priority 5006 When the extent attributes are being merged for display, the priority
5055 is used to determine which extent takes precedence in the event of a 5007 is used to determine which extent takes precedence in the event of a
5056 conflict (two extents whose faces both specify font, for example: the 5008 conflict (two extents whose faces both specify font, for example: the
5057 font of the extent with the higher priority will be used). 5009 font of the extent with the higher priority will be used).
5058 Extents are created with priority 0; priorities may be negative. 5010 Extents are created with priority 0; priorities may be negative.
5059 */ 5011 */
5060 (extent, pri)) 5012 (extent, priority))
5061 { 5013 {
5062 EXTENT e = decode_extent (extent, 0); 5014 EXTENT e = decode_extent (extent, 0);
5063 5015
5064 CHECK_INT (pri); 5016 CHECK_INT (priority);
5065 e = extent_ancestor (e); 5017 e = extent_ancestor (e);
5066 set_extent_priority (e, XINT (pri)); 5018 set_extent_priority (e, XINT (priority));
5067 extent_maybe_changed_for_redisplay (e, 1, 0); 5019 extent_maybe_changed_for_redisplay (e, 1, 0);
5068 return pri; 5020 return priority;
5069 } 5021 }
5070 5022
5071 DEFUN ("extent-priority", Fextent_priority, 1, 1, 0, /* 5023 DEFUN ("extent-priority", Fextent_priority, 1, 1, 0, /*
5072 Return the display priority of EXTENT; see `set-extent-priority'. 5024 Return the display priority of EXTENT; see `set-extent-priority'.
5073 */ 5025 */
5314 plist = Fcopy_sequence (plist); 5266 plist = Fcopy_sequence (plist);
5315 Fcanonicalize_plist (plist, Qnil); 5267 Fcanonicalize_plist (plist, Qnil);
5316 5268
5317 while (!NILP (plist)) 5269 while (!NILP (plist))
5318 { 5270 {
5319 property = Fcar (plist); 5271 property = Fcar (plist); plist = Fcdr (plist);
5320 value = Fcar (Fcdr (plist)); 5272 value = Fcar (plist); plist = Fcdr (plist);
5321 plist = Fcdr (Fcdr (plist));
5322 Fset_extent_property (extent, property, value); 5273 Fset_extent_property (extent, property, value);
5323 } 5274 }
5324 UNGCPRO; 5275 UNGCPRO;
5325 return Qnil; 5276 return Qnil;
5326 } 5277 }
5376 return extent_begin_glyph (e); 5327 return extent_begin_glyph (e);
5377 else if (EQ (property, Qend_glyph)) 5328 else if (EQ (property, Qend_glyph))
5378 return extent_end_glyph (e); 5329 return extent_end_glyph (e);
5379 else 5330 else
5380 { 5331 {
5381 Lisp_Object value; 5332 Lisp_Object value = external_plist_get (extent_plist_addr (e),
5382 5333 property, 0, ERROR_ME);
5383 value = external_plist_get (extent_plist_addr (e), property, 0, 5334 return UNBOUNDP (value) ? default_ : value;
5384 ERROR_ME);
5385 if (UNBOUNDP (value))
5386 return default_;
5387 return value;
5388 } 5335 }
5389 } 5336 }
5390 5337
5391 DEFUN ("extent-properties", Fextent_properties, 1, 1, 0, /* 5338 DEFUN ("extent-properties", Fextent_properties, 1, 1, 0, /*
5392 Return a property list of the attributes of the given extent. 5339 Return a property list of the attributes of the given extent.
5393 Do not modify this list; use `set-extent-property' instead. 5340 Do not modify this list; use `set-extent-property' instead.
5394 */ 5341 */
5395 (extent)) 5342 (extent))
5396 { 5343 {
5397 EXTENT e, anc; 5344 EXTENT e, anc;
5398 Lisp_Object result, face, anc_obj = Qnil; 5345 Lisp_Object result, face, anc_obj;
5346 enum glyph_layout layout;
5399 5347
5400 CHECK_EXTENT (extent); 5348 CHECK_EXTENT (extent);
5401 e = XEXTENT (extent); 5349 e = XEXTENT (extent);
5402 if (!EXTENT_LIVE_P (e)) 5350 if (!EXTENT_LIVE_P (e))
5403 return Fcons (Qdestroyed, Fcons (Qt, Qnil)); 5351 return cons3 (Qdestroyed, Qt, Qnil);
5404 5352
5405 anc = extent_ancestor (e); 5353 anc = extent_ancestor (e);
5406 XSETEXTENT (anc_obj, anc); 5354 XSETEXTENT (anc_obj, anc);
5407 5355
5408 /* For efficiency, use the ancestor for all properties except detached */ 5356 /* For efficiency, use the ancestor for all properties except detached */
5409 5357
5410 result = extent_plist_slot (anc); 5358 result = extent_plist_slot (anc);
5411 face = Fextent_face (anc_obj); 5359
5412 if (!NILP (face)) 5360 if (!NILP (face = Fextent_face (anc_obj)))
5413 result = Fcons (Qface, Fcons (face, result)); 5361 result = cons3 (Qface, face, result);
5414 face = Fextent_mouse_face (anc_obj); 5362
5415 if (!NILP (face)) 5363 if (!NILP (face = Fextent_mouse_face (anc_obj)))
5416 result = Fcons (Qmouse_face, Fcons (face, result)); 5364 result = cons3 (Qmouse_face, face, result);
5417 5365
5418 /* For now continue to include this for backwards compatibility. */ 5366 if ((layout = extent_begin_glyph_layout (anc)) != GL_TEXT)
5419 if (extent_begin_glyph_layout (anc) != GL_TEXT) 5367 {
5420 result = Fcons (Qglyph_layout, 5368 Lisp_Object sym = glyph_layout_to_symbol (layout);
5421 glyph_layout_to_symbol (extent_begin_glyph_layout (anc))); 5369 result = cons3 (Qglyph_layout, sym, result); /* compatibility */
5422 5370 result = cons3 (Qbegin_glyph_layout, sym, result);
5423 if (extent_begin_glyph_layout (anc) != GL_TEXT) 5371 }
5424 result = Fcons (Qbegin_glyph_layout, 5372
5425 glyph_layout_to_symbol (extent_begin_glyph_layout (anc))); 5373 if ((layout = extent_end_glyph_layout (anc)) != GL_TEXT)
5426 if (extent_end_glyph_layout (anc) != GL_TEXT) 5374 result = cons3 (Qend_glyph_layout, glyph_layout_to_symbol (layout), result);
5427 result = Fcons (Qend_glyph_layout,
5428 glyph_layout_to_symbol (extent_end_glyph_layout (anc)));
5429 5375
5430 if (!NILP (extent_end_glyph (anc))) 5376 if (!NILP (extent_end_glyph (anc)))
5431 result = Fcons (Qend_glyph, Fcons (extent_end_glyph (anc), result)); 5377 result = cons3 (Qend_glyph, extent_end_glyph (anc), result);
5378
5432 if (!NILP (extent_begin_glyph (anc))) 5379 if (!NILP (extent_begin_glyph (anc)))
5433 result = Fcons (Qbegin_glyph, Fcons (extent_begin_glyph (anc), result)); 5380 result = cons3 (Qbegin_glyph, extent_begin_glyph (anc), result);
5434 5381
5435 if (extent_priority (anc) != 0) 5382 if (extent_priority (anc) != 0)
5436 result = Fcons (Qpriority, Fcons (make_int (extent_priority (anc)), 5383 result = cons3 (Qpriority, make_int (extent_priority (anc)), result);
5437 result));
5438 5384
5439 if (!NILP (extent_initial_redisplay_function (anc))) 5385 if (!NILP (extent_initial_redisplay_function (anc)))
5440 result = Fcons (Qinitial_redisplay_function, Fcons (extent_initial_redisplay_function (anc), result)); 5386 result = cons3 (Qinitial_redisplay_function,
5387 extent_initial_redisplay_function (anc), result);
5441 5388
5442 if (!NILP (extent_invisible (anc))) 5389 if (!NILP (extent_invisible (anc)))
5443 result = Fcons (Qinvisible, Fcons (extent_invisible (anc), result)); 5390 result = cons3 (Qinvisible, extent_invisible (anc), result);
5444 5391
5445 if (!NILP (extent_read_only (anc))) 5392 if (!NILP (extent_read_only (anc)))
5446 result = Fcons (Qread_only, Fcons (extent_read_only (anc), result)); 5393 result = cons3 (Qread_only, extent_read_only (anc), result);
5447 5394
5448 #define CONS_FLAG(flag, sym) if (extent_normal_field (anc, flag)) \ 5395 if (extent_normal_field (anc, end_open))
5449 result = Fcons (sym, Fcons (Qt, result)) 5396 result = cons3 (Qend_open, Qt, result);
5450 CONS_FLAG (end_open, Qend_open); 5397
5451 CONS_FLAG (start_open, Qstart_open); 5398 if (extent_normal_field (anc, start_open))
5452 CONS_FLAG (detachable, Qdetachable); 5399 result = cons3 (Qstart_open, Qt, result);
5453 CONS_FLAG (duplicable, Qduplicable); 5400
5454 CONS_FLAG (unique, Qunique); 5401 if (extent_normal_field (anc, detachable))
5455 #undef CONS_FLAG 5402 result = cons3 (Qdetachable, Qt, result);
5403
5404 if (extent_normal_field (anc, duplicable))
5405 result = cons3 (Qduplicable, Qt, result);
5406
5407 if (extent_normal_field (anc, unique))
5408 result = cons3 (Qunique, Qt, result);
5456 5409
5457 /* detached is not an inherited property */ 5410 /* detached is not an inherited property */
5458 if (extent_detached_p (e)) 5411 if (extent_detached_p (e))
5459 result = Fcons (Qdetached, Fcons (Qt, result)); 5412 result = cons3 (Qdetached, Qt, result);
5460 5413
5461 return result; 5414 return result;
5462 } 5415 }
5463 5416
5464 5417
5966 return val; 5919 return val;
5967 } 5920 }
5968 } 5921 }
5969 5922
5970 DEFUN ("get-text-property", Fget_text_property, 2, 4, 0, /* 5923 DEFUN ("get-text-property", Fget_text_property, 2, 4, 0, /*
5971 Returns the value of the PROP property at the given position. 5924 Return the value of the PROP property at the given position.
5972 Optional arg OBJECT specifies the buffer or string to look in, and 5925 Optional arg OBJECT specifies the buffer or string to look in, and
5973 defaults to the current buffer. 5926 defaults to the current buffer.
5974 Optional arg AT-FLAG controls what it means for a property to be "at" 5927 Optional arg AT-FLAG controls what it means for a property to be "at"
5975 a position, and has the same meaning as in `extent-at'. 5928 a position, and has the same meaning as in `extent-at'.
5976 This examines only those properties added with `put-text-property'. 5929 This examines only those properties added with `put-text-property'.
5980 { 5933 {
5981 return get_text_property_1 (pos, prop, object, at_flag, 1); 5934 return get_text_property_1 (pos, prop, object, at_flag, 1);
5982 } 5935 }
5983 5936
5984 DEFUN ("get-char-property", Fget_char_property, 2, 4, 0, /* 5937 DEFUN ("get-char-property", Fget_char_property, 2, 4, 0, /*
5985 Returns the value of the PROP property at the given position. 5938 Return the value of the PROP property at the given position.
5986 Optional arg OBJECT specifies the buffer or string to look in, and 5939 Optional arg OBJECT specifies the buffer or string to look in, and
5987 defaults to the current buffer. 5940 defaults to the current buffer.
5988 Optional arg AT-FLAG controls what it means for a property to be "at" 5941 Optional arg AT-FLAG controls what it means for a property to be "at"
5989 a position, and has the same meaning as in `extent-at'. 5942 a position, and has the same meaning as in `extent-at'.
5990 This examines properties on all extents. 5943 This examines properties on all extents.
6139 openness. We are setting the endpoint to be the same as 6092 openness. We are setting the endpoint to be the same as
6140 that of the extent we're about to remove, and we assume 6093 that of the extent we're about to remove, and we assume
6141 (the invariant mentioned above) that extent has the 6094 (the invariant mentioned above) that extent has the
6142 proper endpoint setting, so we just use it. */ 6095 proper endpoint setting, so we just use it. */
6143 set_extent_openness (te, new_start != e_start ? 6096 set_extent_openness (te, new_start != e_start ?
6144 extent_start_open_p (e) : -1, 6097 (int) extent_start_open_p (e) : -1,
6145 new_end != e_end ? 6098 new_end != e_end ?
6146 extent_end_open_p (e) : -1); 6099 (int) extent_end_open_p (e) : -1);
6147 closure->changed_p = 1; 6100 closure->changed_p = 1;
6148 } 6101 }
6149 extent_detach (e); 6102 extent_detach (e);
6150 } 6103 }
6151 else if (e_end <= end) 6104 else if (e_end <= end)
6272 /* If we made it through the loop without reusing an extent 6225 /* If we made it through the loop without reusing an extent
6273 (and we want there to be one) make it now. 6226 (and we want there to be one) make it now.
6274 */ 6227 */
6275 if (!NILP (value) && NILP (closure.the_extent)) 6228 if (!NILP (value) && NILP (closure.the_extent))
6276 { 6229 {
6277 Lisp_Object extent = Qnil; 6230 Lisp_Object extent;
6278 6231
6279 XSETEXTENT (extent, make_extent_internal (object, start, end)); 6232 XSETEXTENT (extent, make_extent_internal (object, start, end));
6280 closure.changed_p = 1; 6233 closure.changed_p = 1;
6281 Fset_extent_property (extent, Qtext_prop, prop); 6234 Fset_extent_property (extent, Qtext_prop, prop);
6282 Fset_extent_property (extent, prop, value); 6235 Fset_extent_property (extent, prop, value);
6373 6326
6374 6327
6375 DEFUN ("add-nonduplicable-text-properties", 6328 DEFUN ("add-nonduplicable-text-properties",
6376 Fadd_nonduplicable_text_properties, 3, 4, 0, /* 6329 Fadd_nonduplicable_text_properties, 3, 4, 0, /*
6377 Add nonduplicable properties to the characters from START to END. 6330 Add nonduplicable properties to the characters from START to END.
6378 (The properties will not be copied when the characters are copied.) 6331 \(The properties will not be copied when the characters are copied.)
6379 The third argument PROPS is a property list specifying the property values 6332 The third argument PROPS is a property list specifying the property values
6380 to add. The optional fourth argument, OBJECT, is the buffer or string 6333 to add. The optional fourth argument, OBJECT, is the buffer or string
6381 containing the text and defaults to the current buffer. Returns t if 6334 containing the text and defaults to the current buffer. Returns t if
6382 any property was changed, nil otherwise. 6335 any property was changed, nil otherwise.
6383 */ 6336 */
6619 syms_of_extents (void) 6572 syms_of_extents (void)
6620 { 6573 {
6621 defsymbol (&Qextentp, "extentp"); 6574 defsymbol (&Qextentp, "extentp");
6622 defsymbol (&Qextent_live_p, "extent-live-p"); 6575 defsymbol (&Qextent_live_p, "extent-live-p");
6623 6576
6624 defsymbol (&Qend_closed, "end-closed");
6625 defsymbol (&Qstart_open, "start-open");
6626 defsymbol (&Qall_extents_closed, "all-extents-closed"); 6577 defsymbol (&Qall_extents_closed, "all-extents-closed");
6627 defsymbol (&Qall_extents_open, "all-extents-open"); 6578 defsymbol (&Qall_extents_open, "all-extents-open");
6628 defsymbol (&Qall_extents_closed_open, "all-extents-closed-open"); 6579 defsymbol (&Qall_extents_closed_open, "all-extents-closed-open");
6629 defsymbol (&Qall_extents_open_closed, "all-extents-open-closed"); 6580 defsymbol (&Qall_extents_open_closed, "all-extents-open-closed");
6630 defsymbol (&Qstart_in_region, "start-in-region"); 6581 defsymbol (&Qstart_in_region, "start-in-region");
6647 defsymbol (&Qduplicable, "duplicable"); 6598 defsymbol (&Qduplicable, "duplicable");
6648 defsymbol (&Qdetachable, "detachable"); 6599 defsymbol (&Qdetachable, "detachable");
6649 defsymbol (&Qpriority, "priority"); 6600 defsymbol (&Qpriority, "priority");
6650 defsymbol (&Qmouse_face, "mouse-face"); 6601 defsymbol (&Qmouse_face, "mouse-face");
6651 defsymbol (&Qinitial_redisplay_function,"initial-redisplay-function"); 6602 defsymbol (&Qinitial_redisplay_function,"initial-redisplay-function");
6652 6603
6653 6604
6654 defsymbol (&Qglyph_layout, "glyph-layout"); /* backwards compatibility */ 6605 defsymbol (&Qglyph_layout, "glyph-layout"); /* backwards compatibility */
6655 defsymbol (&Qbegin_glyph_layout, "begin-glyph-layout"); 6606 defsymbol (&Qbegin_glyph_layout, "begin-glyph-layout");
6656 defsymbol (&Qbegin_glyph_layout, "end-glyph-layout"); 6607 defsymbol (&Qend_glyph_layout, "end-glyph-layout");
6657 defsymbol (&Qoutside_margin, "outside-margin"); 6608 defsymbol (&Qoutside_margin, "outside-margin");
6658 defsymbol (&Qinside_margin, "inside-margin"); 6609 defsymbol (&Qinside_margin, "inside-margin");
6659 defsymbol (&Qwhitespace, "whitespace"); 6610 defsymbol (&Qwhitespace, "whitespace");
6660 /* Qtext defined in general.c */ 6611 /* Qtext defined in general.c */
6661 6612
6673 DEFSUBR (Fextent_detached_p); 6624 DEFSUBR (Fextent_detached_p);
6674 DEFSUBR (Fextent_start_position); 6625 DEFSUBR (Fextent_start_position);
6675 DEFSUBR (Fextent_end_position); 6626 DEFSUBR (Fextent_end_position);
6676 DEFSUBR (Fextent_object); 6627 DEFSUBR (Fextent_object);
6677 DEFSUBR (Fextent_length); 6628 DEFSUBR (Fextent_length);
6678 #if 0
6679 DEFSUBR (Fstack_of_extents);
6680 #endif
6681 6629
6682 DEFSUBR (Fmake_extent); 6630 DEFSUBR (Fmake_extent);
6683 DEFSUBR (Fcopy_extent); 6631 DEFSUBR (Fcopy_extent);
6684 DEFSUBR (Fdelete_extent); 6632 DEFSUBR (Fdelete_extent);
6685 DEFSUBR (Fdetach_extent); 6633 DEFSUBR (Fdetach_extent);