Mercurial > hg > xemacs-beta
comparison src/extents.c @ 70:131b0175ea99 r20-0b30
Import from CVS: tag r20-0b30
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:02:59 +0200 |
parents | 56c54cf7c5b6 |
children | 1ce6082ce73f |
comparison
equal
deleted
inserted
replaced
69:804d1389bcd6 | 70:131b0175ea99 |
---|---|
443 Lisp_Object Qend_closed; | 443 Lisp_Object Qend_closed; |
444 Lisp_Object Qread_only; | 444 Lisp_Object Qread_only; |
445 /* Qhighlight defined in general.c */ | 445 /* Qhighlight defined in general.c */ |
446 Lisp_Object Qunique; | 446 Lisp_Object Qunique; |
447 Lisp_Object Qduplicable; | 447 Lisp_Object Qduplicable; |
448 Lisp_Object Qreplicating; | |
448 Lisp_Object Qdetachable; | 449 Lisp_Object Qdetachable; |
449 Lisp_Object Qpriority; | 450 Lisp_Object Qpriority; |
450 Lisp_Object Qmouse_face; | 451 Lisp_Object Qmouse_face; |
451 | 452 |
452 Lisp_Object Qglyph_layout; /* This exists only for backwards compatibility. */ | 453 Lisp_Object Qglyph_layout; /* This exists only for backwards compatibility. */ |
1576 /* A change to an extent occurred that will change the display, so | 1577 /* A change to an extent occurred that will change the display, so |
1577 notify redisplay. Maybe also recurse over all the extent's | 1578 notify redisplay. Maybe also recurse over all the extent's |
1578 descendants. */ | 1579 descendants. */ |
1579 | 1580 |
1580 static void | 1581 static void |
1581 extent_changed_for_redisplay (EXTENT extent, int descendants_too, | 1582 extent_changed_for_redisplay (EXTENT extent, int descendants_too) |
1582 int invisibility_change) | |
1583 { | 1583 { |
1584 Lisp_Object object; | 1584 Lisp_Object object; |
1585 Lisp_Object rest; | 1585 Lisp_Object rest; |
1586 | 1586 |
1587 /* we could easily encounter a detached extent while traversing the | 1587 /* we could easily encounter a detached extent while traversing the |
1596 { | 1596 { |
1597 /* first mark all of the extent's children. We will lose big-time | 1597 /* first mark all of the extent's children. We will lose big-time |
1598 if there are any circularities here, so we sure as hell better | 1598 if there are any circularities here, so we sure as hell better |
1599 ensure that there aren't. */ | 1599 ensure that there aren't. */ |
1600 LIST_LOOP (rest, XWEAK_LIST_LIST (children)) | 1600 LIST_LOOP (rest, XWEAK_LIST_LIST (children)) |
1601 extent_changed_for_redisplay (XEXTENT (XCAR (rest)), 1, | 1601 extent_changed_for_redisplay (XEXTENT (XCAR (rest)), 1); |
1602 invisibility_change); | |
1603 } | 1602 } |
1604 } | 1603 } |
1605 | 1604 |
1606 /* now mark the extent itself. */ | 1605 /* now mark the extent itself. */ |
1607 | 1606 |
1626 { | 1625 { |
1627 struct buffer *b; | 1626 struct buffer *b; |
1628 b = XBUFFER (object); | 1627 b = XBUFFER (object); |
1629 BUF_FACECHANGE (b)++; | 1628 BUF_FACECHANGE (b)++; |
1630 MARK_EXTENTS_CHANGED; | 1629 MARK_EXTENTS_CHANGED; |
1631 if (invisibility_change) | |
1632 MARK_CLIP_CHANGED; | |
1633 buffer_extent_signal_changed_region (b, | 1630 buffer_extent_signal_changed_region (b, |
1634 extent_endpoint_bufpos (extent, 0), | 1631 extent_endpoint_bufpos (extent, 0), |
1635 extent_endpoint_bufpos (extent, 1)); | 1632 extent_endpoint_bufpos (extent, 1)); |
1636 } | 1633 } |
1637 } | 1634 } |
1640 This is called when properties such as the endpoints, the layout, | 1637 This is called when properties such as the endpoints, the layout, |
1641 or the priority changes. Redisplay will be affected only if | 1638 or the priority changes. Redisplay will be affected only if |
1642 the extent has any displayable attributes. */ | 1639 the extent has any displayable attributes. */ |
1643 | 1640 |
1644 static void | 1641 static void |
1645 extent_maybe_changed_for_redisplay (EXTENT extent, int descendants_too, | 1642 extent_maybe_changed_for_redisplay (EXTENT extent, int descendants_too) |
1646 int invisibility_change) | |
1647 { | 1643 { |
1648 /* Retrieve the ancestor for efficiency */ | 1644 /* Retrieve the ancestor for efficiency */ |
1649 EXTENT anc = extent_ancestor (extent); | 1645 EXTENT anc = extent_ancestor (extent); |
1650 if (!NILP (extent_face (anc)) || !NILP (extent_begin_glyph (anc)) || | 1646 if (!NILP (extent_face (anc)) || !NILP (extent_begin_glyph (anc)) || |
1651 !NILP (extent_end_glyph (anc)) || !NILP (extent_mouse_face (anc)) || | 1647 !NILP (extent_end_glyph (anc)) || !NILP (extent_mouse_face (anc)) || |
1652 !NILP (extent_invisible (anc)) || invisibility_change) | 1648 !NILP (extent_invisible (anc))) |
1653 extent_changed_for_redisplay (extent, descendants_too, | 1649 extent_changed_for_redisplay (extent, descendants_too); |
1654 invisibility_change); | |
1655 } | 1650 } |
1656 | 1651 |
1657 static EXTENT | 1652 static EXTENT |
1658 make_extent_detached (Lisp_Object object) | 1653 make_extent_detached (Lisp_Object object) |
1659 { | 1654 { |
1797 Extent_List *el = extent_extent_list (extent); | 1792 Extent_List *el = extent_extent_list (extent); |
1798 | 1793 |
1799 extent_list_insert (el, extent); | 1794 extent_list_insert (el, extent); |
1800 soe_insert (extent_object (extent), extent); | 1795 soe_insert (extent_object (extent), extent); |
1801 /* only this extent changed */ | 1796 /* only this extent changed */ |
1802 extent_maybe_changed_for_redisplay (extent, 0, | 1797 extent_maybe_changed_for_redisplay (extent, 0); |
1803 !NILP (extent_invisible (extent))); | |
1804 } | 1798 } |
1805 | 1799 |
1806 static void | 1800 static void |
1807 extent_detach (EXTENT extent) | 1801 extent_detach (EXTENT extent) |
1808 { | 1802 { |
1811 if (extent_detached_p (extent)) | 1805 if (extent_detached_p (extent)) |
1812 return; | 1806 return; |
1813 el = extent_extent_list (extent); | 1807 el = extent_extent_list (extent); |
1814 | 1808 |
1815 /* call this before messing with the extent. */ | 1809 /* call this before messing with the extent. */ |
1816 extent_maybe_changed_for_redisplay (extent, 0, | 1810 extent_maybe_changed_for_redisplay (extent, 0); |
1817 !NILP (extent_invisible (extent))); | |
1818 extent_list_delete (el, extent); | 1811 extent_list_delete (el, extent); |
1819 soe_delete (extent_object (extent), extent); | 1812 soe_delete (extent_object (extent), extent); |
1820 set_extent_start (extent, -1); | 1813 set_extent_start (extent, -1); |
1821 set_extent_end (extent, -1); | 1814 set_extent_end (extent, -1); |
1822 } | 1815 } |
1973 { | 1966 { |
1974 assert (EQ (obj, extent_object (after))); | 1967 assert (EQ (obj, extent_object (after))); |
1975 assert (!extent_detached_p (after)); | 1968 assert (!extent_detached_p (after)); |
1976 } | 1969 } |
1977 | 1970 |
1978 el = buffer_or_string_extent_list (obj); | 1971 if (!buffer_or_string_extent_list (obj)) |
1979 if (!el || !extent_list_num_els(el)) | |
1980 return; | 1972 return; |
1981 el = 0; | |
1982 | 1973 |
1983 st = buffer_or_string_bytind_to_memind (obj, from); | 1974 st = buffer_or_string_bytind_to_memind (obj, from); |
1984 en = buffer_or_string_bytind_to_memind (obj, to); | 1975 en = buffer_or_string_bytind_to_memind (obj, to); |
1985 | 1976 |
1986 if (flags & ME_MIGHT_MODIFY_TEXT) | 1977 if (flags & ME_MIGHT_MODIFY_TEXT) |
2322 #ifdef ERROR_CHECK_EXTENTS | 2313 #ifdef ERROR_CHECK_EXTENTS |
2323 sledgehammer_extent_check (obj); | 2314 sledgehammer_extent_check (obj); |
2324 #endif | 2315 #endif |
2325 el = buffer_or_string_extent_list (obj); | 2316 el = buffer_or_string_extent_list (obj); |
2326 | 2317 |
2327 if (!el || !extent_list_num_els(el)) | 2318 if (!el) |
2328 return; | 2319 return; |
2329 | |
2330 /* IMPORTANT! Compute the starting positions of the extents to | 2320 /* IMPORTANT! Compute the starting positions of the extents to |
2331 modify BEFORE doing any modification! Otherwise the starting | 2321 modify BEFORE doing any modification! Otherwise the starting |
2332 position for the second time through the loop might get | 2322 position for the second time through the loop might get |
2333 incorrectly calculated (I got bit by this bug real bad). */ | 2323 incorrectly calculated (I got bit by this bug real bad). */ |
2334 startpos[0] = extent_list_locate_from_pos (el, from+1, 0); | 2324 startpos[0] = extent_list_locate_from_pos (el, from+1, 0); |
2524 Memind mempos = buffer_or_string_bytind_to_memind (obj, pos); | 2514 Memind mempos = buffer_or_string_bytind_to_memind (obj, pos); |
2525 Bytind limit = outside_accessible ? | 2515 Bytind limit = outside_accessible ? |
2526 buffer_or_string_absolute_end_byte (obj) : | 2516 buffer_or_string_absolute_end_byte (obj) : |
2527 buffer_or_string_accessible_end_byte (obj); | 2517 buffer_or_string_accessible_end_byte (obj); |
2528 | 2518 |
2529 if (!bel || !extent_list_num_els(bel)) | 2519 if (!bel) |
2530 return limit; | 2520 return limit; |
2531 | 2521 |
2532 sel = buffer_or_string_stack_of_extents_force (obj)->extents; | 2522 sel = buffer_or_string_stack_of_extents_force (obj)->extents; |
2533 soe_move (obj, mempos); | 2523 soe_move (obj, mempos); |
2534 | 2524 |
2564 Memind mempos = buffer_or_string_bytind_to_memind (obj, pos); | 2554 Memind mempos = buffer_or_string_bytind_to_memind (obj, pos); |
2565 Bytind limit = outside_accessible ? | 2555 Bytind limit = outside_accessible ? |
2566 buffer_or_string_absolute_begin_byte (obj) : | 2556 buffer_or_string_absolute_begin_byte (obj) : |
2567 buffer_or_string_accessible_begin_byte (obj); | 2557 buffer_or_string_accessible_begin_byte (obj); |
2568 | 2558 |
2569 if (!bel || !extent_list_num_els(bel)) | 2559 if (!bel) |
2570 return limit; | 2560 return limit; |
2571 | 2561 |
2572 sel = buffer_or_string_stack_of_extents_force (obj)->extents; | 2562 sel = buffer_or_string_stack_of_extents_force (obj)->extents; |
2573 soe_move (obj, mempos); | 2563 soe_move (obj, mempos); |
2574 | 2564 |
2964 *bp++ = ' '; | 2954 *bp++ = ' '; |
2965 | 2955 |
2966 if (!NILP (extent_read_only (anc))) *bp++ = '%'; | 2956 if (!NILP (extent_read_only (anc))) *bp++ = '%'; |
2967 if (!NILP (extent_mouse_face (anc))) *bp++ = 'H'; | 2957 if (!NILP (extent_mouse_face (anc))) *bp++ = 'H'; |
2968 if (extent_unique_p (anc)) *bp++ = 'U'; | 2958 if (extent_unique_p (anc)) *bp++ = 'U'; |
2959 else if (extent_replicating_p (anc)) *bp++ = 'R'; | |
2969 else if (extent_duplicable_p (anc)) *bp++ = 'D'; | 2960 else if (extent_duplicable_p (anc)) *bp++ = 'D'; |
2970 if (!NILP (extent_invisible (anc))) *bp++ = 'I'; | 2961 if (!NILP (extent_invisible (anc))) *bp++ = 'I'; |
2971 | 2962 |
2972 if (!NILP (extent_read_only (anc)) || !NILP (extent_mouse_face (anc)) || | 2963 if (!NILP (extent_read_only (anc)) || !NILP (extent_mouse_face (anc)) || |
2973 extent_unique_p (anc) || | 2964 extent_unique_p (anc) || extent_replicating_p (anc) || |
2974 extent_duplicable_p (anc) || !NILP (extent_invisible (anc))) | 2965 extent_duplicable_p (anc) || !NILP (extent_invisible (anc))) |
2975 *bp++ = ' '; | 2966 *bp++ = ' '; |
2976 | 2967 |
2977 tail = extent_plist_slot (anc); | 2968 tail = extent_plist_slot (anc); |
2978 | 2969 |
3517 add_extent_to_children_list (XEXTENT (parent), extent); | 3508 add_extent_to_children_list (XEXTENT (parent), extent); |
3518 set_extent_no_chase_aux_field (e, parent, parent); | 3509 set_extent_no_chase_aux_field (e, parent, parent); |
3519 e->flags.has_parent = 1; | 3510 e->flags.has_parent = 1; |
3520 } | 3511 } |
3521 /* changing the parent also changes the properties of all children. */ | 3512 /* changing the parent also changes the properties of all children. */ |
3522 { | 3513 extent_maybe_changed_for_redisplay (e, 1); |
3523 int old_invis = (!NILP (cur_parent) && | |
3524 !NILP (extent_invisible (XEXTENT (cur_parent)))); | |
3525 int new_invis = (!NILP (parent) && | |
3526 !NILP (extent_invisible (XEXTENT (parent)))); | |
3527 | |
3528 extent_maybe_changed_for_redisplay (e, 1, new_invis != old_invis); | |
3529 } | |
3530 | |
3531 return Qnil; | 3514 return Qnil; |
3532 } | 3515 } |
3533 | 3516 |
3534 | 3517 |
3535 /************************************************************************/ | 3518 /************************************************************************/ |
4018 | 4001 |
4019 If optional arg PROPERTY is non-nil, only extents with that property set | 4002 If optional arg PROPERTY is non-nil, only extents with that property set |
4020 on them will be visited. If optional arg VALUE is non-nil, only extents | 4003 on them will be visited. If optional arg VALUE is non-nil, only extents |
4021 whose value for that property is `eq' to VALUE will be visited. | 4004 whose value for that property is `eq' to VALUE will be visited. |
4022 */ | 4005 */ |
4023 (function, object, from, to, maparg, flags, property, value)) | 4006 (function, object, from, to, maparg, flags, property, value)) |
4024 { | 4007 { |
4025 /* This function can GC */ | 4008 /* This function can GC */ |
4026 struct slow_map_extents_arg closure; | 4009 struct slow_map_extents_arg closure; |
4027 unsigned int me_flags; | 4010 unsigned int me_flags; |
4028 Bytind start, end; | 4011 Bytind start, end; |
4377 | 4360 |
4378 Note that in all cases, the start-openness and end-openness of the extents | 4361 Note that in all cases, the start-openness and end-openness of the extents |
4379 considered is ignored. If you want to pay attention to those properties, | 4362 considered is ignored. If you want to pay attention to those properties, |
4380 you should use `map-extents', which gives you more control. | 4363 you should use `map-extents', which gives you more control. |
4381 */ | 4364 */ |
4382 (pos, object, property, before, at_flag)) | 4365 (pos, object, property, before, at_flag)) |
4383 { | 4366 { |
4384 Bytind position; | 4367 Bytind position; |
4385 EXTENT before_extent; | 4368 EXTENT before_extent; |
4386 enum extent_at_flag fl; | 4369 enum extent_at_flag fl; |
4387 | 4370 |
4426 return 0; | 4409 return 0; |
4427 | 4410 |
4428 if (CONSP (closure->iro) && !NILP (Fmemq (prop, closure->iro))) | 4411 if (CONSP (closure->iro) && !NILP (Fmemq (prop, closure->iro))) |
4429 return 0; | 4412 return 0; |
4430 | 4413 |
4431 #if 0 /* Nobody seems to care for this any more -sb */ | |
4432 /* Allow deletion if the extent is completely contained in | 4414 /* Allow deletion if the extent is completely contained in |
4433 the region being deleted. | 4415 the region being deleted. |
4434 This is important for supporting tokens which are internally | 4416 This is important for supporting tokens which are internally |
4435 write-protected, but which can be killed and yanked as a whole. | 4417 write-protected, but which can be killed and yanked as a whole. |
4436 Ignore open/closed distinctions at this point. | 4418 Ignore open/closed distinctions at this point. |
4438 */ | 4420 */ |
4439 if (closure->start != closure->end && | 4421 if (closure->start != closure->end && |
4440 extent_start (extent) >= closure->start && | 4422 extent_start (extent) >= closure->start && |
4441 extent_end (extent) <= closure->end) | 4423 extent_end (extent) <= closure->end) |
4442 return 0; | 4424 return 0; |
4443 #endif | |
4444 | 4425 |
4445 while (1) | 4426 while (1) |
4446 Fsignal (Qbuffer_read_only, (list1 (closure->object))); | 4427 Fsignal (Qbuffer_read_only, (list1 (closure->object))); |
4447 | 4428 |
4448 RETURN_NOT_REACHED(0) | 4429 RETURN_NOT_REACHED(0) |
4624 set_extent_invisible (EXTENT extent, Lisp_Object value) | 4605 set_extent_invisible (EXTENT extent, Lisp_Object value) |
4625 { | 4606 { |
4626 if (!EQ (extent_invisible (extent), value)) | 4607 if (!EQ (extent_invisible (extent), value)) |
4627 { | 4608 { |
4628 set_extent_invisible_1 (extent, value); | 4609 set_extent_invisible_1 (extent, value); |
4629 extent_changed_for_redisplay (extent, 1, 1); | 4610 extent_changed_for_redisplay (extent, 1); |
4630 } | 4611 } |
4631 } | 4612 } |
4632 | 4613 |
4633 /* This function does "memoization" -- similar to the interning | 4614 /* This function does "memoization" -- similar to the interning |
4634 that happens with symbols. Given a list of faces, an equivalent | 4615 that happens with symbols. Given a list of faces, an equivalent |
4781 with faces earlier in the list taking priority over those later in the | 4762 with faces earlier in the list taking priority over those later in the |
4782 list. | 4763 list. |
4783 */ | 4764 */ |
4784 (extent, face)) | 4765 (extent, face)) |
4785 { | 4766 { |
4786 EXTENT e = decode_extent(extent, 0); | 4767 EXTENT e; |
4787 Lisp_Object orig_face = face; | 4768 Lisp_Object orig_face = face; |
4788 | 4769 |
4770 CHECK_EXTENT (extent); | |
4771 e = XEXTENT (extent); | |
4789 /* retrieve the ancestor for efficiency and proper redisplay noting. */ | 4772 /* retrieve the ancestor for efficiency and proper redisplay noting. */ |
4790 e = extent_ancestor (e); | 4773 e = extent_ancestor (e); |
4791 | 4774 |
4792 face = memoize_extent_face_internal (face); | 4775 face = memoize_extent_face_internal (face); |
4793 | 4776 |
4794 extent_face (e) = face; | 4777 extent_face (e) = face; |
4795 extent_changed_for_redisplay (e, 1, 0); | 4778 extent_changed_for_redisplay (e, 1); |
4796 | 4779 |
4797 return orig_face; | 4780 return orig_face; |
4798 } | 4781 } |
4799 | 4782 |
4800 | 4783 |
4830 e = extent_ancestor (e); | 4813 e = extent_ancestor (e); |
4831 | 4814 |
4832 face = memoize_extent_face_internal (face); | 4815 face = memoize_extent_face_internal (face); |
4833 | 4816 |
4834 set_extent_mouse_face (e, face); | 4817 set_extent_mouse_face (e, face); |
4835 extent_changed_for_redisplay (e, 1, 0); | 4818 extent_changed_for_redisplay (e, 1); |
4836 | 4819 |
4837 return orig_face; | 4820 return orig_face; |
4838 } | 4821 } |
4839 | 4822 |
4840 void | 4823 void |
4852 { | 4835 { |
4853 set_extent_end_glyph (extent, glyph); | 4836 set_extent_end_glyph (extent, glyph); |
4854 extent_end_glyph_layout (extent) = layout; | 4837 extent_end_glyph_layout (extent) = layout; |
4855 } | 4838 } |
4856 | 4839 |
4857 extent_changed_for_redisplay (extent, 1, 0); | 4840 extent_changed_for_redisplay (extent, 1); |
4858 } | 4841 } |
4859 | 4842 |
4860 static Lisp_Object | 4843 static Lisp_Object |
4861 glyph_layout_to_symbol (unsigned int layout) | 4844 glyph_layout_to_symbol (unsigned int layout) |
4862 { | 4845 { |
4954 (extent, layout)) | 4937 (extent, layout)) |
4955 { | 4938 { |
4956 EXTENT e = decode_extent (extent, 0); | 4939 EXTENT e = decode_extent (extent, 0); |
4957 e = extent_ancestor (e); | 4940 e = extent_ancestor (e); |
4958 extent_begin_glyph_layout (e) = symbol_to_glyph_layout (layout); | 4941 extent_begin_glyph_layout (e) = symbol_to_glyph_layout (layout); |
4959 extent_maybe_changed_for_redisplay (e, 1, 0); | 4942 extent_maybe_changed_for_redisplay (e, 1); |
4960 return layout; | 4943 return layout; |
4961 } | 4944 } |
4962 | 4945 |
4963 DEFUN ("set-extent-end-glyph-layout", Fset_extent_end_glyph_layout, 2, 2, 0, /* | 4946 DEFUN ("set-extent-end-glyph-layout", Fset_extent_end_glyph_layout, 2, 2, 0, /* |
4964 Set the layout policy of the given extent's end glyph. | 4947 Set the layout policy of the given extent's end glyph. |
4967 (extent, layout)) | 4950 (extent, layout)) |
4968 { | 4951 { |
4969 EXTENT e = decode_extent (extent, 0); | 4952 EXTENT e = decode_extent (extent, 0); |
4970 e = extent_ancestor (e); | 4953 e = extent_ancestor (e); |
4971 extent_end_glyph_layout (e) = symbol_to_glyph_layout (layout); | 4954 extent_end_glyph_layout (e) = symbol_to_glyph_layout (layout); |
4972 extent_maybe_changed_for_redisplay (e, 1, 0); | 4955 extent_maybe_changed_for_redisplay (e, 1); |
4973 return layout; | 4956 return layout; |
4974 } | 4957 } |
4975 | 4958 |
4976 DEFUN ("extent-begin-glyph-layout", Fextent_begin_glyph_layout, 1, 1, 0, /* | 4959 DEFUN ("extent-begin-glyph-layout", Fextent_begin_glyph_layout, 1, 1, 0, /* |
4977 Return the layout policy associated with the given extent's begin glyph. | 4960 Return the layout policy associated with the given extent's begin glyph. |
5006 EXTENT e = decode_extent (extent, 0); | 4989 EXTENT e = decode_extent (extent, 0); |
5007 | 4990 |
5008 CHECK_INT (pri); | 4991 CHECK_INT (pri); |
5009 e = extent_ancestor (e); | 4992 e = extent_ancestor (e); |
5010 set_extent_priority (e, XINT (pri)); | 4993 set_extent_priority (e, XINT (pri)); |
5011 extent_maybe_changed_for_redisplay (e, 1, 0); | 4994 extent_maybe_changed_for_redisplay (e, 1); |
5012 return pri; | 4995 return pri; |
5013 } | 4996 } |
5014 | 4997 |
5015 DEFUN ("extent-priority", Fextent_priority, 1, 1, 0, /* | 4998 DEFUN ("extent-priority", Fextent_priority, 1, 1, 0, /* |
5016 Return the display priority of EXTENT; see `set-extent-priority'. | 4999 Return the display priority of EXTENT; see `set-extent-priority'. |
5090 from the string using `concat' or `substring'. | 5073 from the string using `concat' or `substring'. |
5091 When `insert' or a similar function inserts the | 5074 When `insert' or a similar function inserts the |
5092 string into a buffer, the extents are copied back | 5075 string into a buffer, the extents are copied back |
5093 into the buffer. | 5076 into the buffer. |
5094 | 5077 |
5095 unique Meaningful only in conjunction with `duplicable'. | 5078 replicating Meaningful only in conjunction with `duplicable'. |
5096 When this is set, there may be only one instance | 5079 If this flag is set, extents that are copied from |
5097 of this extent attached at a time: if it is copied | 5080 buffers into strings are made children of the |
5098 to the kill ring and then yanked, the extent is | 5081 original extent. When the string is pasted back |
5099 not copied. If, however, it is killed (removed | 5082 into a buffer, the same extent (i.e. the `eq' |
5100 from the buffer) and then yanked, it will be | 5083 predicate applies) that was originally in the |
5101 re-attached at the new position. | 5084 buffer will be used if possible -- i.e. if the |
5085 extent is detached or the paste location abuts or | |
5086 overlaps the extent. This behavior is compatible | |
5087 with the old "extent replica" behavior and was | |
5088 apparently required by Energize. | |
5089 | |
5090 unique Meaningful only in conjunction with `duplicable' | |
5091 and `replicating'. When this is set, there may be | |
5092 only one instance of this extent attached at a | |
5093 time: if it is copied to the kill ring and then | |
5094 yanked, the extent is not copied. If, however, it | |
5095 is killed (removed from the buffer) and then | |
5096 yanked, it will be re-attached at the new | |
5097 position. | |
5102 | 5098 |
5103 invisible If the value is non-nil, text under this extent | 5099 invisible If the value is non-nil, text under this extent |
5104 may be treated as not present for the purpose of | 5100 may be treated as not present for the purpose of |
5105 redisplay, or may be displayed using an ellipsis | 5101 redisplay, or may be displayed using an ellipsis |
5106 or other marker; see `buffer-invisibility-spec' | 5102 or other marker; see `buffer-invisibility-spec' |
5152 | 5148 |
5153 begin-glyph-layout The layout policy (one of `text', `whitespace', | 5149 begin-glyph-layout The layout policy (one of `text', `whitespace', |
5154 `inside-margin', or `outside-margin') of the extent's | 5150 `inside-margin', or `outside-margin') of the extent's |
5155 begin glyph. | 5151 begin glyph. |
5156 | 5152 |
5157 end-glyph-layout The layout policy of the extent's end glyph. | 5153 end-glyph-layout The layout policy of the extent's end glyph. |
5158 */ | 5154 */ |
5159 (extent, property, value)) | 5155 (extent, property, value)) |
5160 { | 5156 { |
5161 /* This function can GC if property is `keymap' */ | 5157 /* This function can GC if property is `keymap' */ |
5162 EXTENT e = decode_extent (extent, 0); | 5158 EXTENT e = decode_extent (extent, 0); |
5166 set_extent_read_only (e, value); | 5162 set_extent_read_only (e, value); |
5167 else if (EQ (property, Qunique)) | 5163 else if (EQ (property, Qunique)) |
5168 extent_unique_p (e) = !NILP (value); | 5164 extent_unique_p (e) = !NILP (value); |
5169 else if (EQ (property, Qduplicable)) | 5165 else if (EQ (property, Qduplicable)) |
5170 extent_duplicable_p (e) = !NILP (value); | 5166 extent_duplicable_p (e) = !NILP (value); |
5167 else if (EQ (property, Qreplicating)) | |
5168 extent_replicating_p (e) = !NILP (value); | |
5171 else if (EQ (property, Qinvisible)) | 5169 else if (EQ (property, Qinvisible)) |
5172 set_extent_invisible (e, value); | 5170 set_extent_invisible (e, value); |
5173 else if (EQ (property, Qdetachable)) | 5171 else if (EQ (property, Qdetachable)) |
5174 extent_detachable_p (e) = !NILP (value); | 5172 extent_detachable_p (e) = !NILP (value); |
5175 | 5173 |
5252 return (extent_normal_field (e, flag) ? Qt : Qnil) | 5250 return (extent_normal_field (e, flag) ? Qt : Qnil) |
5253 else if (EQ (property, Qstart_open)) RETURN_FLAG (start_open); | 5251 else if (EQ (property, Qstart_open)) RETURN_FLAG (start_open); |
5254 else if (EQ (property, Qend_open)) RETURN_FLAG (end_open); | 5252 else if (EQ (property, Qend_open)) RETURN_FLAG (end_open); |
5255 else if (EQ (property, Qunique)) RETURN_FLAG (unique); | 5253 else if (EQ (property, Qunique)) RETURN_FLAG (unique); |
5256 else if (EQ (property, Qduplicable)) RETURN_FLAG (duplicable); | 5254 else if (EQ (property, Qduplicable)) RETURN_FLAG (duplicable); |
5255 else if (EQ (property, Qreplicating)) RETURN_FLAG (replicating); | |
5257 else if (EQ (property, Qdetachable)) RETURN_FLAG (detachable); | 5256 else if (EQ (property, Qdetachable)) RETURN_FLAG (detachable); |
5258 #undef RETURN_FLAG | 5257 #undef RETURN_FLAG |
5259 /* Support (but don't document...) the obvious antonyms. */ | 5258 /* Support (but don't document...) the obvious antonyms. */ |
5260 else if (EQ (property, Qstart_closed)) | 5259 else if (EQ (property, Qstart_closed)) |
5261 return (extent_start_open_p (e) ? Qnil : Qt); | 5260 return (extent_start_open_p (e) ? Qnil : Qt); |
5354 | 5353 |
5355 #define CONS_FLAG(flag, sym) if (extent_normal_field (anc, flag)) \ | 5354 #define CONS_FLAG(flag, sym) if (extent_normal_field (anc, flag)) \ |
5356 result = Fcons (sym, Fcons (Qt, result)) | 5355 result = Fcons (sym, Fcons (Qt, result)) |
5357 CONS_FLAG (end_open, Qend_open); | 5356 CONS_FLAG (end_open, Qend_open); |
5358 CONS_FLAG (start_open, Qstart_open); | 5357 CONS_FLAG (start_open, Qstart_open); |
5358 CONS_FLAG (replicating, Qreplicating); | |
5359 CONS_FLAG (detachable, Qdetachable); | 5359 CONS_FLAG (detachable, Qdetachable); |
5360 CONS_FLAG (duplicable, Qduplicable); | 5360 CONS_FLAG (duplicable, Qduplicable); |
5361 CONS_FLAG (unique, Qunique); | 5361 CONS_FLAG (unique, Qunique); |
5362 #undef CONS_FLAG | 5362 #undef CONS_FLAG |
5363 | 5363 |
5386 if (EXTENTP (Vlast_highlighted_extent) && | 5386 if (EXTENTP (Vlast_highlighted_extent) && |
5387 EXTENT_LIVE_P (XEXTENT (Vlast_highlighted_extent))) | 5387 EXTENT_LIVE_P (XEXTENT (Vlast_highlighted_extent))) |
5388 { | 5388 { |
5389 /* do not recurse on descendants. Only one extent is highlighted | 5389 /* do not recurse on descendants. Only one extent is highlighted |
5390 at a time. */ | 5390 at a time. */ |
5391 extent_changed_for_redisplay (XEXTENT (Vlast_highlighted_extent), 0, 0); | 5391 extent_changed_for_redisplay (XEXTENT (Vlast_highlighted_extent), 0); |
5392 } | 5392 } |
5393 Vlast_highlighted_extent = Qnil; | 5393 Vlast_highlighted_extent = Qnil; |
5394 if (!NILP (extent_obj) | 5394 if (!NILP (extent_obj) |
5395 && BUFFERP (extent_object (XEXTENT (extent_obj))) | 5395 && BUFFERP (extent_object (XEXTENT (extent_obj))) |
5396 && highlight_p) | 5396 && highlight_p) |
5397 { | 5397 { |
5398 extent_changed_for_redisplay (XEXTENT (extent_obj), 0, 0); | 5398 extent_changed_for_redisplay (XEXTENT (extent_obj), 0); |
5399 Vlast_highlighted_extent = extent_obj; | 5399 Vlast_highlighted_extent = extent_obj; |
5400 } | 5400 } |
5401 } | 5401 } |
5402 | 5402 |
5403 DEFUN ("force-highlight-extent", Fforce_highlight_extent, 1, 2, 0, /* | 5403 DEFUN ("force-highlight-extent", Fforce_highlight_extent, 1, 2, 0, /* |
5613 if (extent_duplicable_p (extent) && | 5613 if (extent_duplicable_p (extent) && |
5614 !run_extent_copy_function (extent, start + closure->from, | 5614 !run_extent_copy_function (extent, start + closure->from, |
5615 end + closure->from)) | 5615 end + closure->from)) |
5616 return 0; | 5616 return 0; |
5617 e = copy_extent (extent, start, end, closure->string); | 5617 e = copy_extent (extent, start, end, closure->string); |
5618 if (extent_replicating_p (extent)) | |
5619 { | |
5620 Lisp_Object e_obj = Qnil, extent_obj = Qnil; | |
5621 | |
5622 XSETEXTENT (e_obj, e); | |
5623 XSETEXTENT (extent_obj, extent); | |
5624 Fset_extent_parent (e_obj, extent_obj); | |
5625 } | |
5618 } | 5626 } |
5619 | 5627 |
5620 return 0; | 5628 return 0; |
5621 } | 5629 } |
5622 | 5630 |
5680 return 0; | 5688 return 0; |
5681 | 5689 |
5682 if (!extent_duplicable_p (extent)) | 5690 if (!extent_duplicable_p (extent)) |
5683 return 0; | 5691 return 0; |
5684 | 5692 |
5685 if (!inside_undo && | 5693 if (!extent_replicating_p (extent)) |
5686 !run_extent_paste_function (extent, new_start, new_end, | 5694 { |
5687 closure->buffer)) | 5695 if (!inside_undo && |
5688 return 0; | 5696 !run_extent_paste_function (extent, new_start, new_end, |
5689 copy_extent (extent, new_start, new_end, closure->buffer); | 5697 closure->buffer)) |
5690 | 5698 return 0; |
5699 copy_extent (extent, new_start, new_end, closure->buffer); | |
5700 } | |
5701 else | |
5702 { | |
5703 Bytind parstart = 0; | |
5704 Bytind parend = 0; | |
5705 Lisp_Object parent_obj = extent_parent (extent); | |
5706 EXTENT parent; | |
5707 | |
5708 if (!EXTENTP (parent_obj)) | |
5709 return 0; | |
5710 parent = XEXTENT (parent_obj); | |
5711 if (!EXTENT_LIVE_P (parent)) | |
5712 return 0; | |
5713 | |
5714 if (!extent_detached_p (parent)) | |
5715 { | |
5716 parstart = extent_endpoint_bytind (parent, 0); | |
5717 parend = extent_endpoint_bytind (parent, 1); | |
5718 } | |
5719 | |
5720 /* #### remove this crap */ | |
5721 #ifdef ENERGIZE | |
5722 /* Energize extents like toplevel-forms can only be pasted | |
5723 in the buffer they come from. This should be parametrized | |
5724 in the generic extent objects. Right now just silently | |
5725 skip the extents if it's not from the same buffer. | |
5726 */ | |
5727 if (!EQ (extent_object (parent), closure->buffer) | |
5728 && energize_extent_data (parent)) | |
5729 return 0; | |
5730 #endif | |
5731 | |
5732 /* If this is a `unique' extent, and it is currently attached | |
5733 somewhere other than here (non-overlapping), then don't copy | |
5734 it (that's what `unique' means). If however it is detached, | |
5735 or if we are inserting inside/adjacent to the original | |
5736 extent, then insert_extent() will simply reattach it, which | |
5737 is what we want. | |
5738 */ | |
5739 if (extent_unique_p (parent) | |
5740 && !extent_detached_p (parent) | |
5741 && (!EQ (extent_object (parent), closure->buffer) | |
5742 || parend > new_end | |
5743 || parstart < new_start)) | |
5744 return 0; | |
5745 | |
5746 insert_extent (parent, new_start, new_end, | |
5747 closure->buffer, !inside_undo); | |
5748 } | |
5691 return 0; | 5749 return 0; |
5692 } | 5750 } |
5693 | 5751 |
5694 /* We have just inserted a section of STRING (starting at POS, of | 5752 /* We have just inserted a section of STRING (starting at POS, of |
5695 length LENGTH) into buffer BUF at OPOINT. Do whatever is necessary | 5753 length LENGTH) into buffer BUF at OPOINT. Do whatever is necessary |
5738 copy_string_extents_1_mapper (EXTENT extent, void *arg) | 5796 copy_string_extents_1_mapper (EXTENT extent, void *arg) |
5739 { | 5797 { |
5740 struct copy_string_extents_1_arg *closure = | 5798 struct copy_string_extents_1_arg *closure = |
5741 (struct copy_string_extents_1_arg *) arg; | 5799 (struct copy_string_extents_1_arg *) arg; |
5742 | 5800 |
5801 if (extent_replicating_p (extent) && | |
5802 EQ (extent_parent (extent), closure->parent_in_question)) | |
5803 { | |
5804 closure->found_extent = extent; | |
5805 return 1; /* stop mapping */ | |
5806 } | |
5807 | |
5743 return 0; | 5808 return 0; |
5744 } | 5809 } |
5745 | 5810 |
5746 static int | 5811 static int |
5747 copy_string_extents_mapper (EXTENT extent, void *arg) | 5812 copy_string_extents_mapper (EXTENT extent, void *arg) |
5761 return 0; | 5826 return 0; |
5762 | 5827 |
5763 new_start = old_start + closure->new_pos - closure->old_pos; | 5828 new_start = old_start + closure->new_pos - closure->old_pos; |
5764 new_end = old_end + closure->new_pos - closure->old_pos; | 5829 new_end = old_end + closure->new_pos - closure->old_pos; |
5765 | 5830 |
5831 if (extent_replicating_p (extent)) | |
5832 { | |
5833 struct copy_string_extents_1_arg closure_1; | |
5834 | |
5835 closure_1.parent_in_question = extent_parent (extent); | |
5836 closure_1.found_extent = 0; | |
5837 | |
5838 /* When adding a replicating extent, we need to make sure | |
5839 that there isn't an existing replicating extent referring | |
5840 to the same parent extent that abuts or overlaps. If so, | |
5841 we merge with that extent rather than adding anew. */ | |
5842 map_extents_bytind (closure->old_pos, closure->old_pos + closure->length, | |
5843 copy_string_extents_1_mapper, | |
5844 (void *) &closure, closure->new_string, 0, | |
5845 /* get all extents that abut the region */ | |
5846 ME_END_CLOSED | ME_ALL_EXTENTS_CLOSED); | |
5847 if (closure_1.found_extent) | |
5848 { | |
5849 Bytecount exstart = | |
5850 extent_endpoint_bytind (closure_1.found_extent, 0); | |
5851 Bytecount exend = | |
5852 extent_endpoint_bytind (closure_1.found_extent, 1); | |
5853 exstart = min (exstart, new_start); | |
5854 exend = max (exend, new_end); | |
5855 set_extent_endpoints (closure_1.found_extent, exstart, exend, Qnil); | |
5856 return 0; | |
5857 } | |
5858 } | |
5859 | |
5766 copy_extent (extent, | 5860 copy_extent (extent, |
5767 old_start + closure->new_pos - closure->old_pos, | 5861 old_start + closure->new_pos - closure->old_pos, |
5768 old_end + closure->new_pos - closure->old_pos, | 5862 old_end + closure->new_pos - closure->old_pos, |
5769 closure->new_string); | 5863 closure->new_string); |
5770 return 0; | 5864 return 0; |
6182 (void *) &closure, object, 0, | 6276 (void *) &closure, object, 0, |
6183 /* get all extents that abut the region */ | 6277 /* get all extents that abut the region */ |
6184 ME_ALL_EXTENTS_CLOSED | ME_END_CLOSED | | 6278 ME_ALL_EXTENTS_CLOSED | ME_END_CLOSED | |
6185 /* it might QUIT or error if the user has | 6279 /* it might QUIT or error if the user has |
6186 fucked with the extent plist. */ | 6280 fucked with the extent plist. */ |
6187 /* #### dmoore - I think this should include | |
6188 ME_MIGHT_MOVE_SOE, since the callback function | |
6189 might recurse back into map_extents_bytind. */ | |
6190 ME_MIGHT_THROW | | 6281 ME_MIGHT_THROW | |
6191 ME_MIGHT_MODIFY_EXTENTS); | 6282 ME_MIGHT_MODIFY_EXTENTS); |
6192 | 6283 |
6193 /* If we made it through the loop without reusing an extent | 6284 /* If we made it through the loop without reusing an extent |
6194 (and we want there to be one) make it now. | 6285 (and we want there to be one) make it now. |
6372 | 6463 |
6373 prop = Fextent_property (extent, Qtext_prop, Qnil); | 6464 prop = Fextent_property (extent, Qtext_prop, Qnil); |
6374 if (NILP (prop)) | 6465 if (NILP (prop)) |
6375 signal_simple_error ("internal error: no text-prop", extent); | 6466 signal_simple_error ("internal error: no text-prop", extent); |
6376 val = Fextent_property (extent, prop, Qnil); | 6467 val = Fextent_property (extent, prop, Qnil); |
6377 #if 0 | |
6378 /* removed by bill perry, 2/9/97 | |
6379 ** This little bit of code would not allow you to have a text property | |
6380 ** with a value of Qnil. This is bad bad bad. | |
6381 */ | |
6382 if (NILP (val)) | 6468 if (NILP (val)) |
6383 signal_simple_error_2 ("internal error: no text-prop", | 6469 signal_simple_error_2 ("internal error: no text-prop", |
6384 extent, prop); | 6470 extent, prop); |
6385 #endif | |
6386 Fput_text_property (from, to, prop, val, Qnil); | 6471 Fput_text_property (from, to, prop, val, Qnil); |
6387 return Qnil; /* important! */ | 6472 return Qnil; /* important! */ |
6388 } | 6473 } |
6389 | 6474 |
6390 /* This function could easily be written in Lisp but the C code wants | 6475 /* This function could easily be written in Lisp but the C code wants |
6572 defsymbol (&Qend_closed, "end-closed"); | 6657 defsymbol (&Qend_closed, "end-closed"); |
6573 defsymbol (&Qread_only, "read-only"); | 6658 defsymbol (&Qread_only, "read-only"); |
6574 /* defsymbol (&Qhighlight, "highlight"); in faces.c */ | 6659 /* defsymbol (&Qhighlight, "highlight"); in faces.c */ |
6575 defsymbol (&Qunique, "unique"); | 6660 defsymbol (&Qunique, "unique"); |
6576 defsymbol (&Qduplicable, "duplicable"); | 6661 defsymbol (&Qduplicable, "duplicable"); |
6662 defsymbol (&Qreplicating, "replicating"); | |
6577 defsymbol (&Qdetachable, "detachable"); | 6663 defsymbol (&Qdetachable, "detachable"); |
6578 defsymbol (&Qpriority, "priority"); | 6664 defsymbol (&Qpriority, "priority"); |
6579 defsymbol (&Qmouse_face, "mouse-face"); | 6665 defsymbol (&Qmouse_face, "mouse-face"); |
6580 | 6666 |
6581 defsymbol (&Qglyph_layout, "glyph-layout"); /* backwards compatibility */ | 6667 defsymbol (&Qglyph_layout, "glyph-layout"); /* backwards compatibility */ |