Mercurial > hg > xemacs-beta
comparison src/extents.c @ 380:8626e4521993 r21-2-5
Import from CVS: tag r21-2-5
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:07:10 +0200 |
parents | 6240c7796c7a |
children | 74fd4e045ea6 |
comparison
equal
deleted
inserted
replaced
379:76b7d63099ad | 380:8626e4521993 |
---|---|
220 #include "elhash.h" | 220 #include "elhash.h" |
221 #include "extents.h" | 221 #include "extents.h" |
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" | |
226 #include "insdel.h" | 225 #include "insdel.h" |
227 #include "keymap.h" | 226 #include "keymap.h" |
228 #include "opaque.h" | 227 #include "opaque.h" |
229 #include "process.h" | 228 #include "process.h" |
230 #include "redisplay.h" | 229 #include "redisplay.h" |
534 char *ptr = ga->array; | 533 char *ptr = ga->array; |
535 int real_gap_loc; | 534 int real_gap_loc; |
536 int old_gap_size; | 535 int old_gap_size; |
537 | 536 |
538 /* If we have to get more space, get enough to last a while. We use | 537 /* If we have to get more space, get enough to last a while. We use |
539 a geometric progession that saves on realloc space. */ | 538 a geometric progression that saves on realloc space. */ |
540 increment += 100 + ga->numels / 8; | 539 increment += 100 + ga->numels / 8; |
541 | 540 |
542 ptr = (char *) xrealloc (ptr, | 541 ptr = (char *) xrealloc (ptr, |
543 (ga->numels + ga->gapsize + increment)*ga->elsize); | 542 (ga->numels + ga->gapsize + increment)*ga->elsize); |
544 if (ptr == 0) | 543 if (ptr == 0) |
912 | 911 |
913 static Lisp_Object | 912 static Lisp_Object |
914 mark_extent_auxiliary (Lisp_Object obj, void (*markobj) (Lisp_Object)) | 913 mark_extent_auxiliary (Lisp_Object obj, void (*markobj) (Lisp_Object)) |
915 { | 914 { |
916 struct extent_auxiliary *data = XEXTENT_AUXILIARY (obj); | 915 struct extent_auxiliary *data = XEXTENT_AUXILIARY (obj); |
917 ((markobj) (data->begin_glyph)); | 916 markobj (data->begin_glyph); |
918 ((markobj) (data->end_glyph)); | 917 markobj (data->end_glyph); |
919 ((markobj) (data->invisible)); | 918 markobj (data->invisible); |
920 ((markobj) (data->children)); | 919 markobj (data->children); |
921 ((markobj) (data->read_only)); | 920 markobj (data->read_only); |
922 ((markobj) (data->mouse_face)); | 921 markobj (data->mouse_face); |
923 ((markobj) (data->initial_redisplay_function)); | 922 markobj (data->initial_redisplay_function); |
924 ((markobj) (data->before_change_functions)); | 923 markobj (data->before_change_functions); |
925 ((markobj) (data->after_change_functions)); | 924 markobj (data->after_change_functions); |
926 return data->parent; | 925 return data->parent; |
927 } | 926 } |
928 | 927 |
929 DEFINE_LRECORD_IMPLEMENTATION ("extent-auxiliary", extent_auxiliary, | 928 DEFINE_LRECORD_IMPLEMENTATION ("extent-auxiliary", extent_auxiliary, |
930 mark_extent_auxiliary, internal_object_printer, | 929 mark_extent_auxiliary, internal_object_printer, |
974 static void soe_invalidate (Lisp_Object obj); | 973 static void soe_invalidate (Lisp_Object obj); |
975 | 974 |
976 static Lisp_Object | 975 static Lisp_Object |
977 mark_extent_info (Lisp_Object obj, void (*markobj) (Lisp_Object)) | 976 mark_extent_info (Lisp_Object obj, void (*markobj) (Lisp_Object)) |
978 { | 977 { |
979 struct extent_info *data = | 978 struct extent_info *data = (struct extent_info *) XEXTENT_INFO (obj); |
980 (struct extent_info *) XEXTENT_INFO (obj); | |
981 int i; | 979 int i; |
982 Extent_List *list; | 980 Extent_List *list = data->extents; |
983 | 981 |
984 /* Vbuffer_defaults and Vbuffer_local_symbols are buffer-like | 982 /* Vbuffer_defaults and Vbuffer_local_symbols are buffer-like |
985 objects that are created specially and never have their extent | 983 objects that are created specially and never have their extent |
986 list initialized (or rather, it is set to zero in | 984 list initialized (or rather, it is set to zero in |
987 nuke_all_buffer_slots()). However, these objects get | 985 nuke_all_buffer_slots()). However, these objects get |
988 garbage-collected so we have to deal. | 986 garbage-collected so we have to deal. |
989 | 987 |
990 (Also the list can be zero when we're dealing with a destroyed | 988 (Also the list can be zero when we're dealing with a destroyed |
991 buffer.) */ | 989 buffer.) */ |
992 | 990 |
993 list = data->extents; | |
994 if (list) | 991 if (list) |
995 { | 992 { |
996 for (i = 0; i < extent_list_num_els (list); i++) | 993 for (i = 0; i < extent_list_num_els (list); i++) |
997 { | 994 { |
998 struct extent *extent = extent_list_at (list, i, 0); | 995 struct extent *extent = extent_list_at (list, i, 0); |
999 Lisp_Object exobj; | 996 Lisp_Object exobj; |
1000 | 997 |
1001 XSETEXTENT (exobj, extent); | 998 XSETEXTENT (exobj, extent); |
1002 ((markobj) (exobj)); | 999 markobj (exobj); |
1003 } | 1000 } |
1004 } | 1001 } |
1005 | 1002 |
1006 return Qnil; | 1003 return Qnil; |
1007 } | 1004 } |
1606 we change an extent in generated-modeline-string, this changes | 1603 we change an extent in generated-modeline-string, this changes |
1607 its parent, which is in `modeline-format', so we should | 1604 its parent, which is in `modeline-format', so we should |
1608 force the modeline to be updated. But how to determine whether | 1605 force the modeline to be updated. But how to determine whether |
1609 a string is a `generated-modeline-string'? Looping through | 1606 a string is a `generated-modeline-string'? Looping through |
1610 all buffers is not very efficient. Should we add all | 1607 all buffers is not very efficient. Should we add all |
1611 `generated-modeline-string' strings to a hashtable? | 1608 `generated-modeline-string' strings to a hash table? |
1612 Maybe efficiency is not the greatest concern here and there's | 1609 Maybe efficiency is not the greatest concern here and there's |
1613 no big loss in looping over the buffers. */ | 1610 no big loss in looping over the buffers. */ |
1614 return; | 1611 return; |
1615 | 1612 |
1616 { | 1613 { |
1822 { | 1819 { |
1823 Lisp_Object obj = extent_object (extent); | 1820 Lisp_Object obj = extent_object (extent); |
1824 Endpoint_Index start, end, exs, exe; | 1821 Endpoint_Index start, end, exs, exe; |
1825 int start_open, end_open; | 1822 int start_open, end_open; |
1826 unsigned int all_extents_flags = flags & ME_ALL_EXTENTS_MASK; | 1823 unsigned int all_extents_flags = flags & ME_ALL_EXTENTS_MASK; |
1827 unsigned int in_region_flags = flags & ME_IN_REGION_MASK; | 1824 unsigned int in_region_flags = flags & ME_IN_REGION_MASK; |
1828 int retval; | 1825 int retval; |
1829 | 1826 |
1830 /* A zero-length region is treated as closed-closed. */ | 1827 /* A zero-length region is treated as closed-closed. */ |
1831 if (from == to) | 1828 if (from == to) |
1832 { | 1829 { |
1833 flags |= ME_END_CLOSED; | 1830 flags |= ME_END_CLOSED; |
1834 flags &= ~ME_START_OPEN; | 1831 flags &= ~ME_START_OPEN; |
1835 } | 1832 } |
1836 | 1833 |
1837 switch (all_extents_flags) | |
1838 { | |
1839 case ME_ALL_EXTENTS_CLOSED: | |
1840 start_open = end_open = 0; break; | |
1841 case ME_ALL_EXTENTS_OPEN: | |
1842 start_open = end_open = 1; break; | |
1843 case ME_ALL_EXTENTS_CLOSED_OPEN: | |
1844 start_open = 0; end_open = 1; break; | |
1845 case ME_ALL_EXTENTS_OPEN_CLOSED: | |
1846 start_open = 1; end_open = 0; break; | |
1847 default: | |
1848 start_open = extent_start_open_p (extent); | |
1849 end_open = extent_end_open_p (extent); | |
1850 break; | |
1851 } | |
1852 | |
1853 /* So is a zero-length extent. */ | 1834 /* So is a zero-length extent. */ |
1854 if (extent_start (extent) == extent_end (extent)) | 1835 if (extent_start (extent) == extent_end (extent)) |
1855 start_open = end_open = 0; | 1836 start_open = 0, end_open = 0; |
1837 /* `all_extents_flags' will almost always be zero. */ | |
1838 else if (all_extents_flags == 0) | |
1839 { | |
1840 start_open = extent_start_open_p (extent); | |
1841 end_open = extent_end_open_p (extent); | |
1842 } | |
1843 else | |
1844 switch (all_extents_flags) | |
1845 { | |
1846 case ME_ALL_EXTENTS_CLOSED: start_open = 0, end_open = 0; break; | |
1847 case ME_ALL_EXTENTS_OPEN: start_open = 1, end_open = 1; break; | |
1848 case ME_ALL_EXTENTS_CLOSED_OPEN: start_open = 0, end_open = 1; break; | |
1849 case ME_ALL_EXTENTS_OPEN_CLOSED: start_open = 1, end_open = 0; break; | |
1850 default: abort(); break; | |
1851 } | |
1856 | 1852 |
1857 start = buffer_or_string_bytind_to_startind (obj, from, | 1853 start = buffer_or_string_bytind_to_startind (obj, from, |
1858 flags & ME_START_OPEN); | 1854 flags & ME_START_OPEN); |
1859 end = buffer_or_string_bytind_to_endind (obj, to, ! (flags & ME_END_CLOSED)); | 1855 end = buffer_or_string_bytind_to_endind (obj, to, ! (flags & ME_END_CLOSED)); |
1860 exs = memind_to_startind (extent_start (extent), start_open); | 1856 exs = memind_to_startind (extent_start (extent), start_open); |
1861 exe = memind_to_endind (extent_end (extent), end_open); | 1857 exe = memind_to_endind (extent_end (extent), end_open); |
1862 | 1858 |
1863 /* It's easy to determine whether an extent lies *outside* the | 1859 /* It's easy to determine whether an extent lies *outside* the |
1864 region -- just determine whether it's completely before | 1860 region -- just determine whether it's completely before |
1865 or completely after the region. Reject all such extents, so | 1861 or completely after the region. Reject all such extents, so |
1866 we're now left with only the extents that overlap the region. | 1862 we're now left with only the extents that overlap the region. |
1868 | 1864 |
1869 if (exs > end || exe < start) | 1865 if (exs > end || exe < start) |
1870 return 0; | 1866 return 0; |
1871 | 1867 |
1872 /* See if any further restrictions are called for. */ | 1868 /* See if any further restrictions are called for. */ |
1873 switch (in_region_flags) | 1869 /* in_region_flags will almost always be zero. */ |
1874 { | 1870 if (in_region_flags == 0) |
1875 case ME_START_IN_REGION: | 1871 retval = 1; |
1876 retval = start <= exs && exs <= end; break; | 1872 else |
1877 case ME_END_IN_REGION: | 1873 switch (in_region_flags) |
1878 retval = start <= exe && exe <= end; break; | 1874 { |
1879 case ME_START_AND_END_IN_REGION: | 1875 case ME_START_IN_REGION: |
1880 retval = start <= exs && exe <= end; break; | 1876 retval = start <= exs && exs <= end; break; |
1881 case ME_START_OR_END_IN_REGION: | 1877 case ME_END_IN_REGION: |
1882 retval = (start <= exs && exs <= end) || (start <= exe && exe <= end); | 1878 retval = start <= exe && exe <= end; break; |
1883 break; | 1879 case ME_START_AND_END_IN_REGION: |
1884 default: | 1880 retval = start <= exs && exe <= end; break; |
1885 retval = 1; break; | 1881 case ME_START_OR_END_IN_REGION: |
1886 } | 1882 retval = (start <= exs && exs <= end) || (start <= exe && exe <= end); |
1883 break; | |
1884 default: | |
1885 abort(); break; | |
1886 } | |
1887 return flags & ME_NEGATE_IN_REGION ? !retval : retval; | 1887 return flags & ME_NEGATE_IN_REGION ? !retval : retval; |
1888 } | 1888 } |
1889 | 1889 |
1890 struct map_extents_struct | 1890 struct map_extents_struct |
1891 { | 1891 { |
2864 /* zeroing isn't really necessary; we only deref `priority' | 2864 /* zeroing isn't really necessary; we only deref `priority' |
2865 and `face' */ | 2865 and `face' */ |
2866 xzero (dummy_lhe_extent); | 2866 xzero (dummy_lhe_extent); |
2867 set_extent_priority (&dummy_lhe_extent, | 2867 set_extent_priority (&dummy_lhe_extent, |
2868 mouse_highlight_priority); | 2868 mouse_highlight_priority); |
2869 /* Need to break up thefollowing expression, due to an */ | 2869 /* Need to break up the following expression, due to an */ |
2870 /* error in the Digital UNIX 3.2g C compiler (Digital */ | 2870 /* error in the Digital UNIX 3.2g C compiler (Digital */ |
2871 /* UNIX Compiler Driver 3.11). */ | 2871 /* UNIX Compiler Driver 3.11). */ |
2872 f = extent_mouse_face (lhe); | 2872 f = extent_mouse_face (lhe); |
2873 extent_face (&dummy_lhe_extent) = f; | 2873 extent_face (&dummy_lhe_extent) = f; |
2874 Dynarr_add (ef->extents, &dummy_lhe_extent); | 2874 Dynarr_add (ef->extents, &dummy_lhe_extent); |
2940 static Lisp_Object | 2940 static Lisp_Object |
2941 mark_extent (Lisp_Object obj, void (*markobj) (Lisp_Object)) | 2941 mark_extent (Lisp_Object obj, void (*markobj) (Lisp_Object)) |
2942 { | 2942 { |
2943 struct extent *extent = XEXTENT (obj); | 2943 struct extent *extent = XEXTENT (obj); |
2944 | 2944 |
2945 ((markobj) (extent_object (extent))); | 2945 markobj (extent_object (extent)); |
2946 ((markobj) (extent_no_chase_normal_field (extent, face))); | 2946 markobj (extent_no_chase_normal_field (extent, face)); |
2947 return extent->plist; | 2947 return extent->plist; |
2948 } | 2948 } |
2949 | 2949 |
2950 static void | 2950 static void |
2951 print_extent_1 (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag) | 2951 print_extent_1 (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag) |
2993 if (NILP (v)) continue; | 2993 if (NILP (v)) continue; |
2994 print_internal (XCAR (tail), printcharfun, escapeflag); | 2994 print_internal (XCAR (tail), printcharfun, escapeflag); |
2995 write_c_string (" ", printcharfun); | 2995 write_c_string (" ", printcharfun); |
2996 } | 2996 } |
2997 | 2997 |
2998 sprintf (buf, "0x%lx", (unsigned long int) ext); | 2998 sprintf (buf, "0x%lx", (long) ext); |
2999 write_c_string (buf, printcharfun); | 2999 write_c_string (buf, printcharfun); |
3000 } | 3000 } |
3001 | 3001 |
3002 static void | 3002 static void |
3003 print_extent (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag) | 3003 print_extent (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag) |
3040 if (print_readably) | 3040 if (print_readably) |
3041 { | 3041 { |
3042 if (!EXTENT_LIVE_P (XEXTENT (obj))) | 3042 if (!EXTENT_LIVE_P (XEXTENT (obj))) |
3043 error ("printing unreadable object #<destroyed extent>"); | 3043 error ("printing unreadable object #<destroyed extent>"); |
3044 else | 3044 else |
3045 error ("printing unreadable object #<extent 0x%p>", | 3045 error ("printing unreadable object #<extent 0x%lx>", |
3046 XEXTENT (obj)); | 3046 (long) XEXTENT (obj)); |
3047 } | 3047 } |
3048 | 3048 |
3049 if (!EXTENT_LIVE_P (XEXTENT (obj))) | 3049 if (!EXTENT_LIVE_P (XEXTENT (obj))) |
3050 write_c_string ("#<destroyed extent", printcharfun); | 3050 write_c_string ("#<destroyed extent", printcharfun); |
3051 else | 3051 else |
3104 extent_no_chase_plist (e2), | 3104 extent_no_chase_plist (e2), |
3105 0, 0, depth + 1); | 3105 0, 0, depth + 1); |
3106 } | 3106 } |
3107 | 3107 |
3108 static int | 3108 static int |
3109 extent_equal (Lisp_Object o1, Lisp_Object o2, int depth) | 3109 extent_equal (Lisp_Object obj1, Lisp_Object obj2, int depth) |
3110 { | 3110 { |
3111 struct extent *e1 = XEXTENT (o1); | 3111 struct extent *e1 = XEXTENT (obj1); |
3112 struct extent *e2 = XEXTENT (o2); | 3112 struct extent *e2 = XEXTENT (obj2); |
3113 return | 3113 return |
3114 (extent_start (e1) == extent_start (e2) && | 3114 (extent_start (e1) == extent_start (e2) && |
3115 extent_end (e1) == extent_end (e2) && | 3115 extent_end (e1) == extent_end (e2) && |
3116 internal_equal (extent_object (e1), extent_object (e2), depth + 1) && | 3116 internal_equal (extent_object (e1), extent_object (e2), depth + 1) && |
3117 properties_equal (extent_ancestor (e1), extent_ancestor (e2), | 3117 properties_equal (extent_ancestor (e1), extent_ancestor (e2), |
3118 depth)); | 3118 depth)); |
3119 } | 3119 } |
3120 | 3120 |
4746 /* To do the memoization, we use a hash table mapping from | 4746 /* To do the memoization, we use a hash table mapping from |
4747 external lists to internal lists. We do `equal' comparisons | 4747 external lists to internal lists. We do `equal' comparisons |
4748 on the keys so the memoization works correctly. | 4748 on the keys so the memoization works correctly. |
4749 | 4749 |
4750 Note that we canonicalize things so that the keys in the | 4750 Note that we canonicalize things so that the keys in the |
4751 hashtable (the external lists) always contain symbols and | 4751 hash table (the external lists) always contain symbols and |
4752 the values (the internal lists) always contain face objects. | 4752 the values (the internal lists) always contain face objects. |
4753 | 4753 |
4754 We also maintain a "reverse" table that maps from the internal | 4754 We also maintain a "reverse" table that maps from the internal |
4755 lists to the external equivalents. The idea here is twofold: | 4755 lists to the external equivalents. The idea here is twofold: |
4756 | 4756 |
4996 if (EQ (layout_obj, Qoutside_margin)) return GL_OUTSIDE_MARGIN; | 4996 if (EQ (layout_obj, Qoutside_margin)) return GL_OUTSIDE_MARGIN; |
4997 if (EQ (layout_obj, Qinside_margin)) return GL_INSIDE_MARGIN; | 4997 if (EQ (layout_obj, Qinside_margin)) return GL_INSIDE_MARGIN; |
4998 if (EQ (layout_obj, Qwhitespace)) return GL_WHITESPACE; | 4998 if (EQ (layout_obj, Qwhitespace)) return GL_WHITESPACE; |
4999 if (EQ (layout_obj, Qtext)) return GL_TEXT; | 4999 if (EQ (layout_obj, Qtext)) return GL_TEXT; |
5000 | 5000 |
5001 signal_simple_error ("unknown glyph layout type", layout_obj); | 5001 signal_simple_error ("Unknown glyph layout type", layout_obj); |
5002 return GL_TEXT; /* unreached */ | 5002 return GL_TEXT; /* unreached */ |
5003 } | 5003 } |
5004 | 5004 |
5005 static Lisp_Object | 5005 static Lisp_Object |
5006 set_extent_glyph_1 (Lisp_Object extent_obj, Lisp_Object glyph, int endp, | 5006 set_extent_glyph_1 (Lisp_Object extent_obj, Lisp_Object glyph, int endp, |
5323 Fset_extent_begin_glyph_layout (extent, value); | 5323 Fset_extent_begin_glyph_layout (extent, value); |
5324 else if (EQ (property, Qbegin_glyph)) | 5324 else if (EQ (property, Qbegin_glyph)) |
5325 Fset_extent_begin_glyph (extent, value, Qnil); | 5325 Fset_extent_begin_glyph (extent, value, Qnil); |
5326 else if (EQ (property, Qend_glyph)) | 5326 else if (EQ (property, Qend_glyph)) |
5327 Fset_extent_end_glyph (extent, value, Qnil); | 5327 Fset_extent_end_glyph (extent, value, Qnil); |
5328 else if (EQ (property, Qstart_open) || | 5328 else if (EQ (property, Qstart_open)) |
5329 EQ (property, Qend_open) || | 5329 set_extent_openness (e, !NILP (value), -1); |
5330 EQ (property, Qstart_closed) || | 5330 else if (EQ (property, Qend_open)) |
5331 EQ (property, Qend_closed)) | 5331 set_extent_openness (e, -1, !NILP (value)); |
5332 { | 5332 /* Support (but don't document...) the obvious *_closed antonyms. */ |
5333 int start_open = -1, end_open = -1; | 5333 else if (EQ (property, Qstart_closed)) |
5334 if (EQ (property, Qstart_open)) | 5334 set_extent_openness (e, NILP (value), -1); |
5335 start_open = !NILP (value); | 5335 else if (EQ (property, Qend_closed)) |
5336 else if (EQ (property, Qend_open)) | 5336 set_extent_openness (e, -1, NILP (value)); |
5337 end_open = !NILP (value); | |
5338 /* Support (but don't document...) the obvious antonyms. */ | |
5339 else if (EQ (property, Qstart_closed)) | |
5340 start_open = NILP (value); | |
5341 else | |
5342 end_open = NILP (value); | |
5343 set_extent_openness (e, start_open, end_open); | |
5344 } | |
5345 else | 5337 else |
5346 { | 5338 { |
5347 if (EQ (property, Qkeymap)) | 5339 if (EQ (property, Qkeymap)) |
5348 while (!NILP (value) && NILP (Fkeymapp (value))) | 5340 while (!NILP (value) && NILP (Fkeymapp (value))) |
5349 value = wrong_type_argument (Qkeymapp, value); | 5341 value = wrong_type_argument (Qkeymapp, value); |
5385 */ | 5377 */ |
5386 (extent, property, default_)) | 5378 (extent, property, default_)) |
5387 { | 5379 { |
5388 EXTENT e = decode_extent (extent, 0); | 5380 EXTENT e = decode_extent (extent, 0); |
5389 | 5381 |
5390 if (EQ (property, Qdetached)) | 5382 if (EQ (property, Qdetached)) |
5391 return extent_detached_p (e) ? Qt : Qnil; | 5383 return extent_detached_p (e) ? Qt : Qnil; |
5392 else if (EQ (property, Qdestroyed)) | 5384 else if (EQ (property, Qdestroyed)) |
5393 return !EXTENT_LIVE_P (e) ? Qt : Qnil; | 5385 return !EXTENT_LIVE_P (e) ? Qt : Qnil; |
5394 #define RETURN_FLAG(flag) return extent_normal_field (e, flag) ? Qt : Qnil | 5386 else if (EQ (property, Qstart_open)) |
5395 else if (EQ (property, Qstart_open)) RETURN_FLAG (start_open); | 5387 return extent_normal_field (e, start_open) ? Qt : Qnil; |
5396 else if (EQ (property, Qend_open)) RETURN_FLAG (end_open); | 5388 else if (EQ (property, Qend_open)) |
5397 else if (EQ (property, Qunique)) RETURN_FLAG (unique); | 5389 return extent_normal_field (e, end_open) ? Qt : Qnil; |
5398 else if (EQ (property, Qduplicable)) RETURN_FLAG (duplicable); | 5390 else if (EQ (property, Qunique)) |
5399 else if (EQ (property, Qdetachable)) RETURN_FLAG (detachable); | 5391 return extent_normal_field (e, unique) ? Qt : Qnil; |
5400 #undef RETURN_FLAG | 5392 else if (EQ (property, Qduplicable)) |
5401 /* Support (but don't document...) the obvious antonyms. */ | 5393 return extent_normal_field (e, duplicable) ? Qt : Qnil; |
5394 else if (EQ (property, Qdetachable)) | |
5395 return extent_normal_field (e, detachable) ? Qt : Qnil; | |
5396 /* Support (but don't document...) the obvious *_closed antonyms. */ | |
5402 else if (EQ (property, Qstart_closed)) | 5397 else if (EQ (property, Qstart_closed)) |
5403 return extent_start_open_p (e) ? Qnil : Qt; | 5398 return extent_start_open_p (e) ? Qnil : Qt; |
5404 else if (EQ (property, Qend_closed)) | 5399 else if (EQ (property, Qend_closed)) |
5405 return extent_end_open_p (e) ? Qnil : Qt; | 5400 return extent_end_open_p (e) ? Qnil : Qt; |
5406 else if (EQ (property, Qpriority)) | 5401 else if (EQ (property, Qpriority)) |
5753 { | 5748 { |
5754 /* This function can GC */ | 5749 /* This function can GC */ |
5755 struct add_string_extents_arg *closure = | 5750 struct add_string_extents_arg *closure = |
5756 (struct add_string_extents_arg *) arg; | 5751 (struct add_string_extents_arg *) arg; |
5757 Bytecount start = extent_endpoint_bytind (extent, 0) - closure->from; | 5752 Bytecount start = extent_endpoint_bytind (extent, 0) - closure->from; |
5758 Bytecount end = extent_endpoint_bytind (extent, 1) - closure->from; | 5753 Bytecount end = extent_endpoint_bytind (extent, 1) - closure->from; |
5759 | 5754 |
5760 if (extent_duplicable_p (extent)) | 5755 if (extent_duplicable_p (extent)) |
5761 { | 5756 { |
5762 EXTENT e; | |
5763 | |
5764 start = max (start, 0); | 5757 start = max (start, 0); |
5765 end = min (end, closure->length); | 5758 end = min (end, closure->length); |
5766 | 5759 |
5767 /* Run the copy-function to give an extent the option of | 5760 /* Run the copy-function to give an extent the option of |
5768 not being copied into the string (or kill ring). | 5761 not being copied into the string (or kill ring). |
5769 */ | 5762 */ |
5770 if (extent_duplicable_p (extent) && | 5763 if (extent_duplicable_p (extent) && |
5771 !run_extent_copy_function (extent, start + closure->from, | 5764 !run_extent_copy_function (extent, start + closure->from, |
5772 end + closure->from)) | 5765 end + closure->from)) |
5773 return 0; | 5766 return 0; |
5774 e = copy_extent (extent, start, end, closure->string); | 5767 copy_extent (extent, start, end, closure->string); |
5775 } | 5768 } |
5776 | 5769 |
5777 return 0; | 5770 return 0; |
5778 } | 5771 } |
5779 | 5772 |
5894 static int | 5887 static int |
5895 copy_string_extents_mapper (EXTENT extent, void *arg) | 5888 copy_string_extents_mapper (EXTENT extent, void *arg) |
5896 { | 5889 { |
5897 struct copy_string_extents_arg *closure = | 5890 struct copy_string_extents_arg *closure = |
5898 (struct copy_string_extents_arg *) arg; | 5891 (struct copy_string_extents_arg *) arg; |
5899 Bytecount old_start, old_end; | 5892 Bytecount old_start, old_end, new_start, new_end; |
5900 Bytecount new_start, new_end; | |
5901 | 5893 |
5902 old_start = extent_endpoint_bytind (extent, 0); | 5894 old_start = extent_endpoint_bytind (extent, 0); |
5903 old_end = extent_endpoint_bytind (extent, 1); | 5895 old_end = extent_endpoint_bytind (extent, 1); |
5904 | 5896 |
5905 old_start = max (closure->old_pos, old_start); | 5897 old_start = max (closure->old_pos, old_start); |
5906 old_end = min (closure->old_pos + closure->length, old_end); | 5898 old_end = min (closure->old_pos + closure->length, old_end); |
5907 | 5899 |
5908 if (old_start >= old_end) | 5900 if (old_start >= old_end) |
5909 return 0; | 5901 return 0; |
5910 | 5902 |
5911 new_start = old_start + closure->new_pos - closure->old_pos; | 5903 new_start = old_start + closure->new_pos - closure->old_pos; |
5912 new_end = old_end + closure->new_pos - closure->old_pos; | 5904 new_end = old_end + closure->new_pos - closure->old_pos; |
5913 | 5905 |
5914 copy_extent (extent, | 5906 copy_extent (extent, new_start, new_end, closure->new_string); |
5915 old_start + closure->new_pos - closure->old_pos, | |
5916 old_end + closure->new_pos - closure->old_pos, | |
5917 closure->new_string); | |
5918 return 0; | 5907 return 0; |
5919 } | 5908 } |
5920 | 5909 |
5921 /* The string NEW_STRING was partially constructed from OLD_STRING. | 5910 /* The string NEW_STRING was partially constructed from OLD_STRING. |
5922 In particular, the section of length LEN starting at NEW_POS in | 5911 In particular, the section of length LEN starting at NEW_POS in |
6512 /* This function can GC */ | 6501 /* This function can GC */ |
6513 Lisp_Object prop, val; | 6502 Lisp_Object prop, val; |
6514 | 6503 |
6515 prop = Fextent_property (extent, Qtext_prop, Qnil); | 6504 prop = Fextent_property (extent, Qtext_prop, Qnil); |
6516 if (NILP (prop)) | 6505 if (NILP (prop)) |
6517 signal_simple_error ("internal error: no text-prop", extent); | 6506 signal_simple_error ("Internal error: no text-prop", extent); |
6518 val = Fextent_property (extent, prop, Qnil); | 6507 val = Fextent_property (extent, prop, Qnil); |
6519 #if 0 | 6508 #if 0 |
6520 /* removed by bill perry, 2/9/97 | 6509 /* removed by bill perry, 2/9/97 |
6521 ** This little bit of code would not allow you to have a text property | 6510 ** This little bit of code would not allow you to have a text property |
6522 ** with a value of Qnil. This is bad bad bad. | 6511 ** with a value of Qnil. This is bad bad bad. |
6523 */ | 6512 */ |
6524 if (NILP (val)) | 6513 if (NILP (val)) |
6525 signal_simple_error_2 ("internal error: no text-prop", | 6514 signal_simple_error_2 ("Internal error: no text-prop", |
6526 extent, prop); | 6515 extent, prop); |
6527 #endif | 6516 #endif |
6528 Fput_text_property (from, to, prop, val, Qnil); | 6517 Fput_text_property (from, to, prop, val, Qnil); |
6529 return Qnil; /* important! */ | 6518 return Qnil; /* important! */ |
6530 } | 6519 } |
6812 See `set-extent-priority'. | 6801 See `set-extent-priority'. |
6813 */ ); | 6802 */ ); |
6814 /* Set mouse-highlight-priority (which ends up being used both for the | 6803 /* Set mouse-highlight-priority (which ends up being used both for the |
6815 mouse-highlighting pseudo-extent and the primary selection extent) | 6804 mouse-highlighting pseudo-extent and the primary selection extent) |
6816 to a very high value because very few extents should override it. | 6805 to a very high value because very few extents should override it. |
6817 1000 gives lots of room below it for different-prioritied extents. | 6806 1000 gives lots of room below it for different-prioritized extents. |
6818 10 doesn't. ediff, for example, likes to use priorities around 100. | 6807 10 doesn't. ediff, for example, likes to use priorities around 100. |
6819 --ben */ | 6808 --ben */ |
6820 mouse_highlight_priority = /* 10 */ 1000; | 6809 mouse_highlight_priority = /* 10 */ 1000; |
6821 | 6810 |
6822 DEFVAR_LISP ("default-text-properties", &Vdefault_text_properties /* | 6811 DEFVAR_LISP ("default-text-properties", &Vdefault_text_properties /* |
6848 | 6837 |
6849 void | 6838 void |
6850 complex_vars_of_extents (void) | 6839 complex_vars_of_extents (void) |
6851 { | 6840 { |
6852 staticpro (&Vextent_face_memoize_hash_table); | 6841 staticpro (&Vextent_face_memoize_hash_table); |
6853 /* The memoize hash-table maps from lists of symbols to lists of | 6842 /* The memoize hash table maps from lists of symbols to lists of |
6854 faces. It needs to be `equal' to implement the memoization. | 6843 faces. It needs to be `equal' to implement the memoization. |
6855 The reverse table maps in the other direction and just needs | 6844 The reverse table maps in the other direction and just needs |
6856 to do `eq' comparison because the lists of faces are already | 6845 to do `eq' comparison because the lists of faces are already |
6857 memoized. */ | 6846 memoized. */ |
6858 Vextent_face_memoize_hash_table = | 6847 Vextent_face_memoize_hash_table = |
6859 make_lisp_hashtable (100, HASHTABLE_VALUE_WEAK, HASHTABLE_EQUAL); | 6848 make_lisp_hash_table (100, HASH_TABLE_VALUE_WEAK, HASH_TABLE_EQUAL); |
6860 staticpro (&Vextent_face_reverse_memoize_hash_table); | 6849 staticpro (&Vextent_face_reverse_memoize_hash_table); |
6861 Vextent_face_reverse_memoize_hash_table = | 6850 Vextent_face_reverse_memoize_hash_table = |
6862 make_lisp_hashtable (100, HASHTABLE_KEY_WEAK, HASHTABLE_EQ); | 6851 make_lisp_hash_table (100, HASH_TABLE_KEY_WEAK, HASH_TABLE_EQ); |
6863 } | 6852 } |