comparison src/extents.c @ 373:6240c7796c7a r21-2b2

Import from CVS: tag r21-2b2
author cvs
date Mon, 13 Aug 2007 11:04:06 +0200
parents cc15677e0335
children 8626e4521993
comparison
equal deleted inserted replaced
372:49e1ed2d7ed8 373:6240c7796c7a
919 ((markobj) (data->invisible)); 919 ((markobj) (data->invisible));
920 ((markobj) (data->children)); 920 ((markobj) (data->children));
921 ((markobj) (data->read_only)); 921 ((markobj) (data->read_only));
922 ((markobj) (data->mouse_face)); 922 ((markobj) (data->mouse_face));
923 ((markobj) (data->initial_redisplay_function)); 923 ((markobj) (data->initial_redisplay_function));
924 ((markobj) (data->before_change_functions));
925 ((markobj) (data->after_change_functions));
924 return data->parent; 926 return data->parent;
925 } 927 }
926 928
927 DEFINE_LRECORD_IMPLEMENTATION ("extent-auxiliary", extent_auxiliary, 929 DEFINE_LRECORD_IMPLEMENTATION ("extent-auxiliary", extent_auxiliary,
928 mark_extent_auxiliary, internal_object_printer, 930 mark_extent_auxiliary, internal_object_printer,
3154 || EQ (prop, Qdetached) 3156 || EQ (prop, Qdetached)
3155 || EQ (prop, Qdestroyed) 3157 || EQ (prop, Qdestroyed)
3156 || EQ (prop, Qpriority) 3158 || EQ (prop, Qpriority)
3157 || EQ (prop, Qface) 3159 || EQ (prop, Qface)
3158 || EQ (prop, Qinitial_redisplay_function) 3160 || EQ (prop, Qinitial_redisplay_function)
3161 || EQ (prop, Qafter_change_functions)
3162 || EQ (prop, Qbefore_change_functions)
3159 || EQ (prop, Qmouse_face) 3163 || EQ (prop, Qmouse_face)
3160 || EQ (prop, Qhighlight) 3164 || EQ (prop, Qhighlight)
3161 || EQ (prop, Qbegin_glyph_layout) 3165 || EQ (prop, Qbegin_glyph_layout)
3162 || EQ (prop, Qend_glyph_layout) 3166 || EQ (prop, Qend_glyph_layout)
3163 || EQ (prop, Qglyph_layout) 3167 || EQ (prop, Qglyph_layout)
4600 map_extents_bytind (from, to, process_extents_for_deletion_mapper, 4604 map_extents_bytind (from, to, process_extents_for_deletion_mapper,
4601 (void *) &closure, object, 0, 4605 (void *) &closure, object, 0,
4602 ME_END_CLOSED | ME_MIGHT_MODIFY_EXTENTS); 4606 ME_END_CLOSED | ME_MIGHT_MODIFY_EXTENTS);
4603 } 4607 }
4604 4608
4609 /* ------------------------------- */
4610 /* report_extent_modification() */
4611 /* ------------------------------- */
4612 struct report_extent_modification_closure {
4613 Lisp_Object buffer;
4614 Bufpos start, end;
4615 int afterp;
4616 int speccount;
4617 };
4618
4619 /* This juggling with the pointer to another file's global variable is
4620 kind of yucky. Perhaps I should just export the variable. */
4621 static int *inside_change_hook_pointer;
4622
4623 static Lisp_Object
4624 report_extent_modification_restore (Lisp_Object buffer)
4625 {
4626 *inside_change_hook_pointer = 0;
4627 if (current_buffer != XBUFFER (buffer))
4628 Fset_buffer (buffer);
4629 return Qnil;
4630 }
4631
4632 static int
4633 report_extent_modification_mapper (EXTENT extent, void *arg)
4634 {
4635 struct report_extent_modification_closure *closure =
4636 (struct report_extent_modification_closure *)arg;
4637 Lisp_Object exobj, startobj, endobj;
4638 Lisp_Object hook = (closure->afterp
4639 ? extent_after_change_functions (extent)
4640 : extent_before_change_functions (extent));
4641 if (NILP (hook))
4642 return 0;
4643
4644 XSETEXTENT (exobj, extent);
4645 XSETINT (startobj, closure->start);
4646 XSETINT (endobj, closure->end);
4647
4648 /* Now that we are sure to call elisp, set up an unwind-protect so
4649 inside_change_hook gets restored in case we throw. Also record
4650 the current buffer, in case we change it. Do the recording only
4651 once. */
4652 if (closure->speccount == -1)
4653 {
4654 closure->speccount = specpdl_depth ();
4655 record_unwind_protect (report_extent_modification_restore,
4656 Fcurrent_buffer ());
4657 }
4658
4659 /* The functions will expect closure->buffer to be the current
4660 buffer, so change it if it isn't. */
4661 if (current_buffer != XBUFFER (closure->buffer))
4662 Fset_buffer (closure->buffer);
4663
4664 /* #### It's a shame that we can't use any of the existing run_hook*
4665 functions here. This is so because all of them work with
4666 symbols, to be able to retrieve default values of local hooks.
4667 <sigh> */
4668
4669 if (!CONSP (hook) || EQ (XCAR (hook), Qlambda))
4670 call3 (hook, exobj, startobj, endobj);
4671 else
4672 {
4673 Lisp_Object tail;
4674 EXTERNAL_LIST_LOOP (tail, hook)
4675 call3 (XCAR (tail), exobj, startobj, endobj);
4676 }
4677 return 0;
4678 }
4679
4680 void
4681 report_extent_modification (Lisp_Object buffer, Bufpos start, Bufpos end,
4682 int *inside, int afterp)
4683 {
4684 struct report_extent_modification_closure closure;
4685
4686 closure.buffer = buffer;
4687 closure.start = start;
4688 closure.end = end;
4689 closure.afterp = afterp;
4690 closure.speccount = -1;
4691
4692 inside_change_hook_pointer = inside;
4693 *inside = 1;
4694
4695 map_extents (start, end, report_extent_modification_mapper, (void *)&closure,
4696 buffer, NULL, ME_MIGHT_CALL_ELISP);
4697
4698 if (closure.speccount == -1)
4699 *inside = 0;
4700 else
4701 {
4702 /* We mustn't unbind when closure.speccount != -1 because
4703 map_extents_bytind has already done that. */
4704 assert (*inside == 0);
4705 }
4706 }
4707
4605 4708
4606 /************************************************************************/ 4709 /************************************************************************/
4607 /* extent properties */ 4710 /* extent properties */
4608 /************************************************************************/ 4711 /************************************************************************/
4609 4712
5199 Fset_extent_priority (extent, value); 5302 Fset_extent_priority (extent, value);
5200 else if (EQ (property, Qface)) 5303 else if (EQ (property, Qface))
5201 Fset_extent_face (extent, value); 5304 Fset_extent_face (extent, value);
5202 else if (EQ (property, Qinitial_redisplay_function)) 5305 else if (EQ (property, Qinitial_redisplay_function))
5203 Fset_extent_initial_redisplay_function (extent, value); 5306 Fset_extent_initial_redisplay_function (extent, value);
5307 else if (EQ (property, Qbefore_change_functions))
5308 set_extent_before_change_functions (e, value);
5309 else if (EQ (property, Qafter_change_functions))
5310 set_extent_after_change_functions (e, value);
5204 else if (EQ (property, Qmouse_face)) 5311 else if (EQ (property, Qmouse_face))
5205 Fset_extent_mouse_face (extent, value); 5312 Fset_extent_mouse_face (extent, value);
5206 /* Obsolete: */ 5313 /* Obsolete: */
5207 else if (EQ (property, Qhighlight)) 5314 else if (EQ (property, Qhighlight))
5208 Fset_extent_mouse_face (extent, Qhighlight); 5315 Fset_extent_mouse_face (extent, Qhighlight);
5304 return extent_invisible (e); 5411 return extent_invisible (e);
5305 else if (EQ (property, Qface)) 5412 else if (EQ (property, Qface))
5306 return Fextent_face (extent); 5413 return Fextent_face (extent);
5307 else if (EQ (property, Qinitial_redisplay_function)) 5414 else if (EQ (property, Qinitial_redisplay_function))
5308 return extent_initial_redisplay_function (e); 5415 return extent_initial_redisplay_function (e);
5416 else if (EQ (property, Qbefore_change_functions))
5417 return extent_before_change_functions (e);
5418 else if (EQ (property, Qafter_change_functions))
5419 return extent_after_change_functions (e);
5309 else if (EQ (property, Qmouse_face)) 5420 else if (EQ (property, Qmouse_face))
5310 return Fextent_mouse_face (extent); 5421 return Fextent_mouse_face (extent);
5311 /* Obsolete: */ 5422 /* Obsolete: */
5312 else if (EQ (property, Qhighlight)) 5423 else if (EQ (property, Qhighlight))
5313 return !NILP (Fextent_mouse_face (extent)) ? Qt : Qnil; 5424 return !NILP (Fextent_mouse_face (extent)) ? Qt : Qnil;
5379 result = cons3 (Qpriority, make_int (extent_priority (anc)), result); 5490 result = cons3 (Qpriority, make_int (extent_priority (anc)), result);
5380 5491
5381 if (!NILP (extent_initial_redisplay_function (anc))) 5492 if (!NILP (extent_initial_redisplay_function (anc)))
5382 result = cons3 (Qinitial_redisplay_function, 5493 result = cons3 (Qinitial_redisplay_function,
5383 extent_initial_redisplay_function (anc), result); 5494 extent_initial_redisplay_function (anc), result);
5495
5496 if (!NILP (extent_before_change_functions (anc)))
5497 result = cons3 (Qbefore_change_functions,
5498 extent_before_change_functions (anc), result);
5499
5500 if (!NILP (extent_after_change_functions (anc)))
5501 result = cons3 (Qafter_change_functions,
5502 extent_after_change_functions (anc), result);
5384 5503
5385 if (!NILP (extent_invisible (anc))) 5504 if (!NILP (extent_invisible (anc)))
5386 result = cons3 (Qinvisible, extent_invisible (anc), result); 5505 result = cons3 (Qinvisible, extent_invisible (anc), result);
5387 5506
5388 if (!NILP (extent_read_only (anc))) 5507 if (!NILP (extent_read_only (anc)))
6721 extent_auxiliary_defaults.priority = 0; 6840 extent_auxiliary_defaults.priority = 0;
6722 extent_auxiliary_defaults.invisible = Qnil; 6841 extent_auxiliary_defaults.invisible = Qnil;
6723 extent_auxiliary_defaults.read_only = Qnil; 6842 extent_auxiliary_defaults.read_only = Qnil;
6724 extent_auxiliary_defaults.mouse_face = Qnil; 6843 extent_auxiliary_defaults.mouse_face = Qnil;
6725 extent_auxiliary_defaults.initial_redisplay_function = Qnil; 6844 extent_auxiliary_defaults.initial_redisplay_function = Qnil;
6845 extent_auxiliary_defaults.before_change_functions = Qnil;
6846 extent_auxiliary_defaults.after_change_functions = Qnil;
6726 } 6847 }
6727 6848
6728 void 6849 void
6729 complex_vars_of_extents (void) 6850 complex_vars_of_extents (void)
6730 { 6851 {