comparison src/extents.c @ 438:84b14dcb0985 r21-2-27

Import from CVS: tag r21-2-27
author cvs
date Mon, 13 Aug 2007 11:32:25 +0200
parents 3ecd8885ac67
children 8de8e3f6228a
comparison
equal deleted inserted replaced
437:e2a4e8b94b82 438:84b14dcb0985
4616 Bufpos start, end; 4616 Bufpos start, end;
4617 int afterp; 4617 int afterp;
4618 int speccount; 4618 int speccount;
4619 }; 4619 };
4620 4620
4621 /* This juggling with the pointer to another file's global variable is
4622 kind of yucky. Perhaps I should just export the variable. */
4623 static int *inside_change_hook_pointer;
4624
4625 static Lisp_Object 4621 static Lisp_Object
4626 report_extent_modification_restore (Lisp_Object buffer) 4622 report_extent_modification_restore (Lisp_Object buffer)
4627 { 4623 {
4628 *inside_change_hook_pointer = 0;
4629 if (current_buffer != XBUFFER (buffer)) 4624 if (current_buffer != XBUFFER (buffer))
4630 Fset_buffer (buffer); 4625 Fset_buffer (buffer);
4631 return Qnil; 4626 return Qnil;
4632 } 4627 }
4633 4628
4648 XSETINT (endobj, closure->end); 4643 XSETINT (endobj, closure->end);
4649 4644
4650 /* Now that we are sure to call elisp, set up an unwind-protect so 4645 /* Now that we are sure to call elisp, set up an unwind-protect so
4651 inside_change_hook gets restored in case we throw. Also record 4646 inside_change_hook gets restored in case we throw. Also record
4652 the current buffer, in case we change it. Do the recording only 4647 the current buffer, in case we change it. Do the recording only
4653 once. */ 4648 once.
4649
4650 One confusing thing here is that our caller never actually calls
4651 unbind_to (closure.speccount, Qnil). This is because
4652 map_extents_bytind() unbinds before, and with a smaller
4653 speccount. The additional unbind_to() in
4654 report_extent_modification() would cause XEmacs to abort. */
4654 if (closure->speccount == -1) 4655 if (closure->speccount == -1)
4655 { 4656 {
4656 closure->speccount = specpdl_depth (); 4657 closure->speccount = specpdl_depth ();
4657 record_unwind_protect (report_extent_modification_restore, 4658 record_unwind_protect (report_extent_modification_restore,
4658 Fcurrent_buffer ()); 4659 Fcurrent_buffer ());
4664 Fset_buffer (closure->buffer); 4665 Fset_buffer (closure->buffer);
4665 4666
4666 /* #### It's a shame that we can't use any of the existing run_hook* 4667 /* #### It's a shame that we can't use any of the existing run_hook*
4667 functions here. This is so because all of them work with 4668 functions here. This is so because all of them work with
4668 symbols, to be able to retrieve default values of local hooks. 4669 symbols, to be able to retrieve default values of local hooks.
4669 <sigh> */ 4670 <sigh>
4671
4672 #### Idea: we could set up a dummy symbol, and call the hook
4673 functions on *that*. */
4670 4674
4671 if (!CONSP (hook) || EQ (XCAR (hook), Qlambda)) 4675 if (!CONSP (hook) || EQ (XCAR (hook), Qlambda))
4672 call3 (hook, exobj, startobj, endobj); 4676 call3 (hook, exobj, startobj, endobj);
4673 else 4677 else
4674 { 4678 {
4675 Lisp_Object tail; 4679 Lisp_Object tail;
4676 EXTERNAL_LIST_LOOP (tail, hook) 4680 EXTERNAL_LIST_LOOP (tail, hook)
4681 /* #### Shouldn't this perform the same Fset_buffer() check as
4682 above? */
4677 call3 (XCAR (tail), exobj, startobj, endobj); 4683 call3 (XCAR (tail), exobj, startobj, endobj);
4678 } 4684 }
4679 return 0; 4685 return 0;
4680 } 4686 }
4681 4687
4682 void 4688 void
4683 report_extent_modification (Lisp_Object buffer, Bufpos start, Bufpos end, 4689 report_extent_modification (Lisp_Object buffer, Bufpos start, Bufpos end,
4684 int *inside, int afterp) 4690 int afterp)
4685 { 4691 {
4686 struct report_extent_modification_closure closure; 4692 struct report_extent_modification_closure closure;
4687 4693
4688 closure.buffer = buffer; 4694 closure.buffer = buffer;
4689 closure.start = start; 4695 closure.start = start;
4690 closure.end = end; 4696 closure.end = end;
4691 closure.afterp = afterp; 4697 closure.afterp = afterp;
4692 closure.speccount = -1; 4698 closure.speccount = -1;
4693 4699
4694 inside_change_hook_pointer = inside;
4695 *inside = 1;
4696
4697 map_extents (start, end, report_extent_modification_mapper, (void *)&closure, 4700 map_extents (start, end, report_extent_modification_mapper, (void *)&closure,
4698 buffer, NULL, ME_MIGHT_CALL_ELISP); 4701 buffer, NULL, ME_MIGHT_CALL_ELISP);
4699
4700 if (closure.speccount == -1)
4701 *inside = 0;
4702 else
4703 {
4704 /* We mustn't unbind when closure.speccount != -1 because
4705 map_extents_bytind has already done that. */
4706 assert (*inside == 0);
4707 }
4708 } 4702 }
4709 4703
4710 4704
4711 /************************************************************************/ 4705 /************************************************************************/
4712 /* extent properties */ 4706 /* extent properties */