comparison src/extents.c @ 5879:77d7b77909c2

Move extents.c to working in byte positions only; fix a bug, extent_detach() src/ChangeLog addition: 2015-03-27 Aidan Kehoe <kehoea@parhasard.net> Fix a small bug, extent_detach(); minimise needless char-byte conversion, extents.c, sticking to byte positions in general in this file. * extents.c: * extents.c (signal_single_extent_changed): Pass byte endpoints to gutter_extent_signal_changed_region_maybe(), buffer_extent_signal_changed_region(). * extents.c (extent_detach): Call signal_extent_changed() correctly, pass both extent endpoints rather than just the byte and character variants of the start. * extents.c (struct report_extent_modification_closure): Do this in terms of byte positions. * extents.c (report_extent_modification_mapper): Use byte positions, only converting to characters when we are definitely calling Lisp. * extents.c (report_extent_modification): Use byte positions in this API, move the byte-char conversion to our callers, simplifying extents.c (it all now works in byte positions). * extents.h: Update report_extent_modification's prototype. * gutter.c (gutter_extent_signal_changed_region_maybe): Use byte positions here, avoids needless byte-char conversion. * gutter.h: Update the prototype here. * insdel.c: * insdel.c (buffer_extent_signal_changed_region): Implement this in terms of byte positions. * insdel.c (signal_before_change): * insdel.c (signal_after_change): Call report_extent_modification() with byte positions, doing the char->byte conversion here rather than leaving it to extents.c. * insdel.h: * insdel.h (struct each_buffer_change_data): The extent unchanged info now describes bytecounts.
author Aidan Kehoe <kehoea@parhasard.net>
date Fri, 27 Mar 2015 23:39:49 +0000
parents 56144c8593a8
children
comparison
equal deleted inserted replaced
5878:916187a03b82 5879:77d7b77909c2
1471 only extents attached to buffers have changed. */ 1471 only extents attached to buffers have changed. */
1472 1472
1473 if (!in_modeline_generation) 1473 if (!in_modeline_generation)
1474 MARK_EXTENTS_CHANGED; 1474 MARK_EXTENTS_CHANGED;
1475 gutter_extent_signal_changed_region_maybe 1475 gutter_extent_signal_changed_region_maybe
1476 (object, extent_endpoint_char (extent, 0), 1476 (object, extent_endpoint_byte (extent, 0),
1477 extent_endpoint_char (extent, 1)); 1477 extent_endpoint_byte (extent, 1));
1478 } 1478 }
1479 else if (BUFFERP (object)) 1479 else if (BUFFERP (object))
1480 { 1480 {
1481 struct buffer *b; 1481 struct buffer *b;
1482 b = XBUFFER (object); 1482 b = XBUFFER (object);
1484 MARK_EXTENTS_CHANGED; 1484 MARK_EXTENTS_CHANGED;
1485 if (NILP (property) ? !NILP (extent_invisible (anc)) : 1485 if (NILP (property) ? !NILP (extent_invisible (anc)) :
1486 EQ (property, Qinvisible)) 1486 EQ (property, Qinvisible))
1487 MARK_CLIP_CHANGED; 1487 MARK_CLIP_CHANGED;
1488 buffer_extent_signal_changed_region 1488 buffer_extent_signal_changed_region
1489 (b, extent_endpoint_char (extent, 0), 1489 (b, extent_endpoint_byte (extent, 0),
1490 extent_endpoint_char (extent, 1)); 1490 extent_endpoint_byte (extent, 1));
1491 } 1491 }
1492 } 1492 }
1493 1493
1494 /* Check for syntax table property change */ 1494 /* Check for syntax table property change */
1495 if (NILP (property) ? !NILP (Fextent_property (wrap_extent (extent), 1495 if (NILP (property) ? !NILP (Fextent_property (wrap_extent (extent),
1694 if (extent_detached_p (extent)) 1694 if (extent_detached_p (extent))
1695 return; 1695 return;
1696 el = extent_extent_list (extent); 1696 el = extent_extent_list (extent);
1697 1697
1698 /* call this before messing with the extent. */ 1698 /* call this before messing with the extent. */
1699 signal_extent_changed (extent, Qnil, 1699 signal_extent_changed (extent, Qnil, extent_endpoint_byte (extent, 0),
1700 extent_endpoint_byte (extent, 0), 1700 extent_endpoint_byte (extent, 1), 0);
1701 extent_endpoint_char (extent, 0),
1702 0);
1703 extent_list_delete (el, extent); 1701 extent_list_delete (el, extent);
1704 soe_delete (extent_object (extent), extent); 1702 soe_delete (extent_object (extent), extent);
1705 set_extent_start (extent, -1); 1703 set_extent_start (extent, -1);
1706 set_extent_end (extent, -1); 1704 set_extent_end (extent, -1);
1707 } 1705 }
4630 /* ------------------------------- */ 4628 /* ------------------------------- */
4631 4629
4632 struct report_extent_modification_closure 4630 struct report_extent_modification_closure
4633 { 4631 {
4634 Lisp_Object buffer; 4632 Lisp_Object buffer;
4635 Charxpos start, end; 4633 Bytexpos start, end;
4636 int afterp; 4634 int afterp;
4637 int speccount; 4635 int speccount;
4638 }; 4636 };
4639 4637
4640 static Lisp_Object 4638 static Lisp_Object
4656 : extent_before_change_functions (extent)); 4654 : extent_before_change_functions (extent));
4657 if (NILP (hook)) 4655 if (NILP (hook))
4658 return 0; 4656 return 0;
4659 4657
4660 exobj = wrap_extent (extent); 4658 exobj = wrap_extent (extent);
4661 startobj = make_fixnum (closure->start); 4659 startobj
4662 endobj = make_fixnum (closure->end); 4660 = make_fixnum (buffer_or_string_bytexpos_to_charxpos
4661 (extent_object (extent), closure->start));
4662 endobj
4663 = make_fixnum (buffer_or_string_bytexpos_to_charxpos
4664 (extent_object (extent), closure->end));
4663 4665
4664 /* Now that we are sure to call elisp, set up an unwind-protect so 4666 /* Now that we are sure to call elisp, set up an unwind-protect so
4665 inside_change_hook gets restored in case we throw. Also record 4667 inside_change_hook gets restored in case we throw. Also record
4666 the current buffer, in case we change it. Do the recording only 4668 the current buffer, in case we change it. Do the recording only
4667 once. 4669 once.
4702 } 4704 }
4703 return 0; 4705 return 0;
4704 } 4706 }
4705 4707
4706 void 4708 void
4707 report_extent_modification (Lisp_Object buffer, Charbpos start, Charbpos end, 4709 report_extent_modification (Lisp_Object buffer, Bytexpos start, Bytexpos end,
4708 int afterp) 4710 int afterp)
4709 { 4711 {
4710 struct report_extent_modification_closure closure; 4712 struct report_extent_modification_closure closure;
4711 4713
4712 closure.buffer = buffer; 4714 closure.buffer = buffer;
4713 closure.start = start; 4715 closure.start = start;
4714 closure.end = end; 4716 closure.end = end;
4715 closure.afterp = afterp; 4717 closure.afterp = afterp;
4716 closure.speccount = -1; 4718 closure.speccount = -1;
4717 4719
4718 map_extents (charbpos_to_bytebpos (XBUFFER (buffer), start), 4720 map_extents (start, end, report_extent_modification_mapper,
4719 charbpos_to_bytebpos (XBUFFER (buffer), end), 4721 (void *)&closure, buffer, NULL, ME_MIGHT_CALL_ELISP);
4720 report_extent_modification_mapper, (void *)&closure,
4721 buffer, NULL, ME_MIGHT_CALL_ELISP);
4722 } 4722 }
4723 4723
4724 4724
4725 /************************************************************************/ 4725 /************************************************************************/
4726 /* extent properties */ 4726 /* extent properties */